Passed
Push — master ( 80ddec...cae974 )
by Caen
03:33 queued 12s
created

MarkdownPost::constructMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
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\Hyde;
8
use Hyde\Framework\Models\FrontMatter;
9
use Hyde\Framework\Models\Markdown;
10
use Illuminate\Support\Collection;
11
12
/**
13
 * @see \Hyde\Framework\Testing\Feature\MarkdownPostTest
14
 */
15
class MarkdownPost extends AbstractMarkdownPage
16
{
17
    use BlogPostSchema;
18
19
    public static string $sourceDirectory = '_posts';
20
    public static string $outputDirectory = 'posts';
21
    public static string $template = 'hyde::layouts/post';
22
23
    public function __construct(string $identifier = '', ?FrontMatter $matter = null, ?Markdown $markdown = null)
24
    {
25
        parent::__construct($identifier, $matter, $markdown);
26
    }
27
28
    protected function constructPageSchemas(): void
29
    {
30
        parent::constructPageSchemas();
31
        $this->constructBlogPostSchema();
32
    }
33
34
    /** @deprecated v0.58.x-beta (may be moved to BlogPostSchema) */
35
    public function getCanonicalLink(): string
36
    {
37
        return Hyde::url($this->getCurrentPagePath().'.html');
38
    }
39
40
    /** @deprecated v0.58.x-beta (pull description instead) */
41
    public function getPostDescription(): string
42
    {
43
        return $this->description;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->description could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
44
    }
45
46
    public static function getLatestPosts(): Collection
47
    {
48
        return static::all()->sortByDesc('matter.date');
49
    }
50
}
51