notes as $note) { if ($note->type?->id === $type) { return $note; } } return new NullEditorDoc(); } /** * Get all notess by type name * * @param string $type EditorDoc type * * @return EditorDoc * * @since 1.0.0 */ public function getEditorDocByTypeName(string $type) : EditorDoc { foreach ($this->notes as $note) { if ($note->type?->title === $type) { return $note; } } return new NullEditorDoc(); } /** * Get all notess by type name * * @param string $type EditorDoc type * * @return EditorDoc[] * * @since 1.0.0 */ public function getEditorDocsByTypeName(string $type) : array { $notes = []; foreach ($this->notes as $note) { if ($note->type?->title === $type) { $notes[] = $note; } } return $notes; } /** * Check if file with a certain type name exists * * @param string $type Type name * * @return bool * * @since 1.0.0 */ public function hasEditorDocTypeName(string $type) : bool { foreach ($this->notes as $note) { if ($note->type?->title === $type) { return true; } } return false; } }