OgLocaleTag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 51
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepForRender() 0 10 3
A init() 0 3 1
A rules() 0 9 1
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS
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) 2019 nystudio107
10
 */
11
12
namespace nystudio107\seomatic\models\metatag;
13
14
use nystudio107\seomatic\helpers\Localization as LocalizationHelper;
15
use nystudio107\seomatic\models\MetaTag;
16
17
/**
18
 * @author    nystudio107
19
 * @package   Seomatic
20
 * @since     3.2.30
21
 */
22
class OgLocaleTag extends MetaTag
23
{
24
    // Constants
25
    // =========================================================================
26
27
    public const ITEM_TYPE = 'OgLocaleTag';
28
29
    // Static Methods
30
    // =========================================================================
31
32
    // Public Properties
33
    // =========================================================================
34
35
    // Public Methods
36
    // =========================================================================
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function init(): void
42
    {
43
        parent::init();
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function rules(): array
50
    {
51
        $rules = parent::rules();
52
        $rules = array_merge($rules, [
53
            // content in this case should be a string
54
            [['content'], 'string'],
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['content'])) {
68
                $data['content'] = LocalizationHelper::normalizeOgLocaleLanguage($data['content']);
69
            }
70
        }
71
72
        return $shouldRender;
73
    }
74
}
75