Passed
Push — master ( 4b9d48...79626d )
by Caen
03:22 queued 15s
created

Schemas::getBlogPostArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Hyde\Framework\Concerns\FrontMatter\Schemas;
4
5
/**
6
 * Class representation of all the available schema traits with helpers to access them.
7
 *
8
 * All front matter properties are always optional in HydePHP.
9
 */
10
final class Schemas
11
{
12
    public static function all(): array
13
    {
14
        return [
15
            'PageSchema' => self::get(PageSchema::class),
16
            'BlogPostSchema' => self::get(BlogPostSchema::class),
17
            'DocumentationPageSchema' => self::get(DocumentationPageSchema::class),
18
        ];
19
    }
20
21
    public static function getPageArray(): array
22
    {
23
        return [
24
            'title' => 'string',
25
            'navigation' => 'array',
26
            'canonicalUrl' => 'string',
27
        ];
28
    }
29
30
    public static function getBlogPostArray(): array
31
    {
32
        return [
33
            'title' => 'string',
34
            'description' => 'string',
35
            'category' => 'string',
36
            'date' => 'string',
37
            'author' => 'string|array',
38
            'image' => 'string|array',
39
        ];
40
    }
41
42
    public static function getDocumentationPageArray(): array
43
    {
44
        return [
45
            'category' => 'string',
46
            'label' => 'string',
47
            'hidden' => 'bool',
48
            'priority' => 'int',
49
        ];
50
    }
51
52
    public static function get(string $schema): array
53
    {
54
        return match ($schema) {
55
            PageSchema::class => self::getPageArray(),
56
            BlogPostSchema::class => self::getBlogPostArray(),
57
            DocumentationPageSchema::class => self::getDocumentationPageArray(),
58
            default => throw new \Exception("Schema $schema does not exist."),
59
        };
60
    }
61
}
62