Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| Author | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| create | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| all | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Hyde\Facades; |
| 6 | |
| 7 | use Hyde\Framework\Features\Blogging\Models\PostAuthor; |
| 8 | use Illuminate\Support\Collection; |
| 9 | |
| 10 | /** |
| 11 | * Allows you to easily add pre-defined authors for your blog posts. |
| 12 | * |
| 13 | * @see \Hyde\Framework\Features\Blogging\Models\PostAuthor |
| 14 | */ |
| 15 | class Author |
| 16 | { |
| 17 | /** |
| 18 | * Construct a new Post Author. For Hyde to discover this author, |
| 19 | * you must call this method from your hyde.php config file. |
| 20 | * |
| 21 | * @see https://hydephp.com/docs/1.x/customization#authors |
| 22 | * |
| 23 | * @param string $username The username of the author. This is the key used to find authors in the config. |
| 24 | * @param string|null $name The optional display name of the author, leave blank to use the username. |
| 25 | * @param string|null $website The author's optional website URL. Website, Twitter, etc. |
| 26 | */ |
| 27 | public static function create(string $username, ?string $name = null, ?string $website = null): PostAuthor |
| 28 | { |
| 29 | return new PostAuthor($username, $name, $website); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get a Post Author instance from the config. If no author matching the username is found, |
| 34 | * a new Post Author instance will be created with just username supplied to the method. |
| 35 | */ |
| 36 | public static function get(string $username): PostAuthor |
| 37 | { |
| 38 | return PostAuthor::get($username); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get all the defined Post Author instances from the config. |
| 43 | * |
| 44 | * @return \Illuminate\Support\Collection<\Hyde\Framework\Features\Blogging\Models\PostAuthor> |
| 45 | */ |
| 46 | public static function all(): Collection |
| 47 | { |
| 48 | return PostAuthor::all(); |
| 49 | } |
| 50 | } |