Passed
Push — master ( a995d1...6dc0a9 )
by Caen
03:12 queued 12s
created

MarkdownPost   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLatestPosts() 0 3 1
1
<?php
2
3
namespace Hyde\Framework\Models\Pages;
4
5
use Hyde\Framework\Concerns\BaseMarkdownPage;
6
use Hyde\Framework\Contracts\FrontMatter\BlogPostSchema;
7
use Hyde\Framework\Foundation\PageCollection;
8
use Hyde\Framework\Models\Markdown\Markdown;
9
use Hyde\Framework\Models\Support\Author;
10
use Hyde\Framework\Models\Support\DateString;
11
use Hyde\Framework\Models\Support\Image;
12
13
/**
14
 * Page class for Markdown posts.
15
 *
16
 * Markdown posts are stored in the _posts directory and using the .md extension.
17
 * The Markdown will be compiled to HTML using the blog post layout to the _site/posts/ directory.
18
 *
19
 * @see https://hydephp.com/docs/master/blog-posts
20
 */
21
class MarkdownPost extends BaseMarkdownPage implements BlogPostSchema
22
{
23
    public static string $sourceDirectory = '_posts';
24
    public static string $outputDirectory = 'posts';
25
    public static string $template = 'hyde::layouts/post';
26
27
    public string $title;
28
    public ?string $description = null;
29
    public ?string $category = null;
30
    public ?DateString $date = null;
31
    public ?Author $author = null;
32
    public ?Image $image = null;
33
34
    /** @return \Hyde\Framework\Foundation\PageCollection<\Hyde\Framework\Models\Pages\MarkdownPost> */
35
    public static function getLatestPosts(): PageCollection
36
    {
37
        return static::all()->sortByDesc('matter.date');
38
    }
39
}
40