AuthorLink::prepForRender()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 12
ccs 0
cts 7
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS 3.x
4
 *
5
 * A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
6
 * and flexible
7
 *
8
 * @link      https://nystudio107.com
9
 * @copyright Copyright (c) 2017 nystudio107
10
 */
11
12
namespace nystudio107\seomatic\models\metalink;
13
14
use craft\helpers\StringHelper;
15
use nystudio107\seomatic\helpers\UrlHelper;
16
17
use nystudio107\seomatic\models\MetaLink;
18
19
/**
20
 * @author    nystudio107
21
 * @package   Seomatic
22
 * @since     3.0.0
23
 */
24
class AuthorLink extends MetaLink
25
{
26
    // Constants
27
    // =========================================================================
28
29
    const ITEM_TYPE = 'AuthorLink';
30
31
    // Static Methods
32
    // =========================================================================
33
34
    // Public Properties
35
    // =========================================================================
36
37
    // Public Methods
38
    // =========================================================================
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function init()
44
    {
45
        parent::init();
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function rules()
52
    {
53
        $rules = parent::rules();
54
        $rules = array_merge($rules, [
55
        ]);
56
57
        return $rules;
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public function prepForRender(&$data): bool
64
    {
65
        $shouldRender = parent::prepForRender($data);
66
        if ($shouldRender) {
67
            if (!empty($data['href'])) {
68
                $data['href'] = UrlHelper::absoluteUrlWithProtocol(
69
                    StringHelper::toLowerCase($data['href'])
70
                );
71
            }
72
        }
73
74
        return $shouldRender;
75
    }
76
}
77