Passed
Push — master ( 9b4e67...25f483 )
by Caen
02:57 queued 12s
created

BlogPostSchema::constructBlogPostSchema()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 7
rs 10
c 3
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Concerns\FrontMatter\Schemas;
4
5
use Hyde\Framework\Actions\Constructors\ConfiguresFeaturedImageForPost;
6
use Hyde\Framework\Actions\Constructors\FindsAuthorForPost;
7
use Hyde\Framework\Models\Author;
8
use Hyde\Framework\Models\DateString;
9
use Hyde\Framework\Models\Image;
10
11
trait BlogPostSchema
12
{
13
    /** @example "My New Post" */
14
    public string $title;
15
16
    /** @example "A short description" */
17
    public ?string $description = null;
18
19
    /** @example "general", "my favorite recipes" */
20
    public ?string $category = null;
21
22
    /**
23
     * The date the post was published.
24
     *
25
     * @example 'YYYY-MM-DD [HH:MM]' (Must be parsable by `strtotime()`)
26
     * @yamlType string|optional
27
     */
28
    public ?DateString $date = null;
29
30
    /**
31
     * @example See author section
32
     * @yamlType string|array|optional
33
     */
34
    public ?Author $author = null;
35
36
    /**
37
     * @example See image section
38
     * @yamlType string|array|optional
39
     */
40
    public ?Image $image = null;
41
42
    protected function constructBlogPostSchema(): void
43
    {
44
        $this->category = $this->matter('category');
0 ignored issues
show
Bug introduced by
It seems like matter() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

44
        /** @scrutinizer ignore-call */ 
45
        $this->category = $this->matter('category');
Loading history...
45
        $this->description = $this->matter('description', substr($this->markdown, 0, 125).'...');
46
        $this->date = $this->matter('date') !== null ? new DateString($this->matter('date')) : null;
47
        $this->author = FindsAuthorForPost::run($this);
48
        $this->image = ConfiguresFeaturedImageForPost::run($this);
49
    }
50
}
51