Completed
Pull Request — master (#1)
by
unknown
04:06
created

RenderedPage::setFeaturedImageUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace hiqdev\yii2\modules\pages\models;
4
5
use hipanel\helpers\Url;
6
7
class RenderedPage extends AbstractPage
8
{
9
    /** @var null|string */
10
    private $featuredImageUrl;
11
12
    /** @var null|string */
13
    private $slug;
14
15
    /** @var null|string */
16
    private $keywords;
17
18
    /** @var null|string */
19
    private $description;
20
21
    public function render(array $params = [])
22
    {
23
        $this->view->registerMetaTag([
24
            'name' => 'keywords',
25
            'content' => $this->keywords,
26
        ]);
27
28
        $this->view->registerMetaTag([
29
            'name' => 'description',
30
            'content' => $this->description,
31
        ]);
32
33
        return $this->text;
34
    }
35
36
    public function renderMiniature()
37
    {
38
        $url = Url::to('/pages/' . $this->slug);
39
40
        return <<<HTML
41
<a href="$url"><h1>$this->title</h1></a>
42
<img src="$this->featuredImageUrl" alt="">
43
$this->text
44
HTML;
45
    }
46
47
    /**
48
     * @param null|string $slug
49
     */
50
    public function setSlug(?string $slug): void
51
    {
52
        $this->slug = $slug;
53
    }
54
55
    /**
56
     * @param null|string $keywords
57
     */
58
    public function setKeywords(?string $keywords): void
59
    {
60
        $this->keywords = $keywords;
61
    }
62
63
    /**
64
     * @param null|string $description
65
     */
66
    public function setDescription(?string $description): void
67
    {
68
        $this->description = $description;
69
    }
70
71
    /**
72
     * @param null|string $featuredImageUrl
73
     */
74
    public function setFeaturedImageUrl(?string $featuredImageUrl): void
75
    {
76
        $this->featuredImageUrl = $featuredImageUrl;
77
    }
78
}
79