| Total Complexity | 9 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 14 | class FindsTitleForPage |
||
| 15 | { |
||
| 16 | public static function run(AbstractPage $page): string |
||
| 17 | { |
||
| 18 | return (new static($page))->findTitleForPage(); |
||
| 19 | } |
||
| 20 | |||
| 21 | protected function __construct(protected AbstractPage $page) |
||
| 22 | { |
||
| 23 | } |
||
| 24 | |||
| 25 | protected function findTitleForPage(): string |
||
| 26 | { |
||
| 27 | return $this->page instanceof AbstractMarkdownPage |
||
| 28 | ? $this->findTitleForMarkdownPage() |
||
| 29 | : Hyde::makeTitle($this->page->identifier); |
||
| 30 | } |
||
| 31 | |||
| 32 | protected function findTitleForMarkdownPage(): string |
||
| 33 | { |
||
| 34 | return $this->page->matter('title') |
||
| 35 | ?? $this->findTitleFromMarkdownHeadings() |
||
| 36 | ?? Hyde::makeTitle($this->page->identifier); |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function findTitleFromMarkdownHeadings(): ?string |
||
| 50 | } |
||
| 51 | } |
||
| 52 |