Passed
Push — master ( f9c187...0868ed )
by Caen
02:55 queued 12s
created

MarkdownPost   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 7
c 4
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getLatestPosts() 0 3 1
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