Passed
Push — master ( f4f5f5...69e5ba )
by Caen
02:58 queued 12s
created

Homepages   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 1
eloc 22
c 7
b 0
f 0
dl 0
loc 51
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$2 ➔ blank() 0 8 1
A options() 0 6 1
welcome() 0 8 ?
A exists() 0 3 1
posts() 0 8 ?
A get() 0 3 1
blank() 0 8 ?
A hp$1 ➔ posts() 0 8 1
A hp$0 ➔ welcome() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework\Features\Templates;
6
7
use Illuminate\Support\Collection;
8
9
/** @internal */
10
final class Homepages
11
{
12
    public static function options(): Collection
13
    {
14
        return new Collection([
0 ignored issues
show
Bug introduced by
array('welcome' => self:...lank' => self::blank()) of type array<string,anonymous//...plates/Homepages.php$2> is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $items of Illuminate\Support\Collection::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

14
        return new Collection(/** @scrutinizer ignore-type */ [
Loading history...
15
            'welcome' => self::welcome(),
16
            'posts' => self::posts(),
17
            'blank' => self::blank(),
18
        ]);
19
    }
20
21
    public static function exists(string $page): bool
22
    {
23
        return self::options()->has($page);
24
    }
25
26
    public static function get(string $page): ?PublishableContract
27
    {
28
        return self::options()->get($page);
29
    }
30
31
    public static function welcome(): PublishableContract
32
    {
33
        return new class extends PublishableView
34
        {
35
            protected static string $title = 'Welcome';
36
            protected static string $desc = 'The default welcome page.';
37
            protected static string $path = 'resources/views/homepages/welcome.blade.php';
38
            protected static ?string $outputPath = 'index.blade.php';
39
        };
40
    }
41
42
    public static function posts(): PublishableContract
43
    {
44
        return new class extends PublishableView
45
        {
46
            protected static string $title = 'Posts Feed';
47
            protected static string $desc = 'A feed of your latest posts. Perfect for a blog site!';
48
            protected static string $path = 'resources/views/homepages/post-feed.blade.php';
49
            protected static ?string $outputPath = 'index.blade.php';
50
        };
51
    }
52
53
    public static function blank(): PublishableContract
54
    {
55
        return new class extends PublishableView
56
        {
57
            protected static string $title = 'Blank Starter';
58
            protected static string $desc = 'A blank Blade template with just the base layout.';
59
            protected static string $path = 'resources/views/homepages/blank.blade.php';
60
            protected static ?string $outputPath = 'index.blade.php';
61
        };
62
    }
63
}
64