ElementWithHandle   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 63
ccs 0
cts 45
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B rules() 0 37 1
A attributeLabels() 0 10 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/spark
7
 */
8
9
namespace flipbox\spark\elements;
10
11
use Craft;
12
use craft\base\Element;
13
use craft\validators\HandleValidator;
14
use flipbox\spark\helpers\ElementHelper;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
abstract class ElementWithHandle extends Element
21
{
22
23
    /**
24
     * @var string Handle
25
     */
26
    public $handle;
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function rules()
32
    {
33
34
        return array_merge(
35
            parent::rules(),
36
            [
37
                [
38
                    [
39
                        'handle'
40
                    ],
41
                    HandleValidator::class
42
                ],
43
                [
44
                    [
45
                        'handle'
46
                    ],
47
                    'required'
48
                ],
49
                [
50
                    [
51
                        'handle'
52
                    ],
53
                    'string',
54
                    'max' => 255
55
                ],
56
                [
57
                    [
58
                        'handle'
59
                    ],
60
                    'safe',
61
                    'on' => [
62
                        ElementHelper::SCENARIO_DEFAULT
63
                    ]
64
                ]
65
            ]
66
        );
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function attributeLabels()
73
    {
74
75
        return array_merge(
76
            parent::attributeLabels(),
77
            [
78
                'handle' => Craft::t('app', 'Handle')
79
            ]
80
        );
81
    }
82
}
83