Passed
Push — master ( df324d...7773d7 )
by Caen
03:06 queued 14s
created

MarkdownPost::getPostDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Models\Pages;
4
5
use Hyde\Framework\Concerns\FrontMatter\Schemas\BlogPostSchema;
6
use Hyde\Framework\Contracts\AbstractMarkdownPage;
7
use Hyde\Framework\Models\FrontMatter;
8
use Hyde\Framework\Models\Markdown;
9
use Hyde\Framework\PageCollection;
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
    protected function constructPageSchemas(): void
28
    {
29
        parent::constructPageSchemas();
30
        $this->constructBlogPostSchema();
31
    }
32
33
    /** @return \Hyde\Framework\PageCollection<\Hyde\Framework\Models\Pages\MarkdownPost> */
34
    public static function getLatestPosts(): PageCollection
35
    {
36
        return static::all()->sortByDesc('matter.date');
37
    }
38
}
39