Author::all()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Facades;
6
7
use Hyde\Framework\Features\Blogging\Models\PostAuthor;
0 ignored issues
show
Bug introduced by
The type Hyde\Framework\Features\Blogging\Models\PostAuthor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Support\Collection;
9
10
use function compact;
11
12
/**
13
 * Allows you to easily add pre-defined authors for your blog posts.
14
 *
15
 * @see \Hyde\Framework\Features\Blogging\Models\PostAuthor
16
 */
17
class Author
18
{
19
    /**
20
     * Configuration helper method to define a new blog post author, with better IDE support.
21
     *
22
     * The returned array will then be used by the framework to create a new PostAuthor instance.
23
     *
24
     * @see https://hydephp.com/docs/1.x/customization#authors
25
     *
26
     * @param  string|null  $name  The optional display name of the author, leave blank to use the username.
27
     * @param  string|null  $website  The author's optional website URL. Website, Twitter, etc.
28
     * @param  string|null  $bio  The author's optional biography text. Markdown supported.
29
     * @param  string|null  $avatar  The author's optional avatar image. Supports both image names and full URIs.
30
     * @param  array<string, string>|null  $socials  The author's optional social media links/handles.
31
     */
32
    public static function create(?string $name = null, ?string $website = null, ?string $bio = null, ?string $avatar = null, ?array $socials = null): array
33
    {
34
        return compact('name', 'website', 'bio', 'avatar', 'socials');
35
    }
36
37
    /**
38
     * Get a Post Author instance by username, or null if not found.
39
     */
40
    public static function get(string $username): ?PostAuthor
41
    {
42
        return PostAuthor::get($username);
43
    }
44
45
    /**
46
     * Get all the defined Post Author instances from the config.
47
     *
48
     * @return \Illuminate\Support\Collection<\Hyde\Framework\Features\Blogging\Models\PostAuthor>
49
     */
50
    public static function all(): Collection
51
    {
52
        return PostAuthor::all();
53
    }
54
}
55