Passed
Branch decouple-schema-constructors (79d259)
by Caen
02:51
created

MarkdownPost::constructPageSchemas()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Models\Pages;
4
5
use Hyde\Framework\Concerns\AbstractMarkdownPage;
6
use Hyde\Framework\Concerns\FrontMatter\Schemas\BlogPostSchema;
7
use Hyde\Framework\Foundation\PageCollection;
8
use Hyde\Framework\Models\FrontMatter;
9
use Hyde\Framework\Models\Markdown;
10
11
/**
12
 * @see \Hyde\Framework\Testing\Feature\MarkdownPostTest
13
 */
14
class MarkdownPost extends AbstractMarkdownPage
15
{
16
    use BlogPostSchema;
17
18
    public static string $sourceDirectory = '_posts';
19
    public static string $outputDirectory = 'posts';
20
    public static string $template = 'hyde::layouts/post';
21
22
    public function __construct(string $identifier = '', ?FrontMatter $matter = null, ?Markdown $markdown = null)
23
    {
24
        parent::__construct($identifier, $matter, $markdown);
25
    }
26
27
    /** @return \Hyde\Framework\Foundation\PageCollection<\Hyde\Framework\Models\Pages\MarkdownPost> */
28
    public static function getLatestPosts(): PageCollection
29
    {
30
        return static::all()->sortByDesc('matter.date');
31
    }
32
}
33