Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Author
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 create
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 all
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Hyde\Framework\Helpers;
4
5use Hyde\Framework\Models\Author as AuthorModel;
6use Illuminate\Support\Collection;
7
8/**
9 * @see \Tests\Feature\AuthorHelperTest
10 */
11class Author
12{
13    public static function create(string $username, ?string $name = null, ?string $website = null): AuthorModel
14    {
15        return new AuthorModel($username, [
16            'name' => $name,
17            'website'=> $website,
18        ]);
19    }
20
21    public static function all(): Collection
22    {
23        return new Collection(config('authors', []));
24    }
25
26    public static function get(string $username): AuthorModel
27    {
28        return static::all()->firstWhere('username', $username)
29            ?? static::create($username);
30    }
31}