| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | protected function findAuthorForPost(): Author|null |
||
| 23 | { |
||
| 24 | if ($this->page->matter('author') !== null) { |
||
| 25 | if (is_string($this->page->matter('author'))) { |
||
| 26 | // If the author is a string, we assume it's a username, |
||
| 27 | // so we'll try to find the author in the config |
||
| 28 | return Author::get($this->page->matter('author')); |
||
| 29 | } |
||
| 30 | if (is_array($this->page->matter('author'))) { |
||
| 31 | // If the author is an array, we'll assume it's a user |
||
| 32 | // with one-off custom data, so we create a new author. |
||
| 33 | // In the future we may want to merge config data with custom data |
||
| 34 | return new Author($this->getUsername(), $this->page->matter('author')); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return null; |
||
| 39 | } |
||
| 46 |