ModelWithHandle   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 57
ccs 0
cts 39
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B handleRules() 0 34 1
A handleAttributeLabel() 0 7 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\models\traits;
10
11
use Craft;
12
use craft\validators\HandleValidator;
13
use flipbox\spark\helpers\ModelHelper;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 2.0.0
18
 */
19
trait ModelWithHandle
20
{
21
22
    /**
23
     * @var string Handle
24
     */
25
    public $handle;
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function handleRules()
31
    {
32
33
        return [
34
            [
35
                [
36
                    'handle'
37
                ],
38
                HandleValidator::class
39
            ],
40
            [
41
                [
42
                    'handle'
43
                ],
44
                'required'
45
            ],
46
            [
47
                [
48
                    'handle'
49
                ],
50
                'string',
51
                'max' => 255
52
            ],
53
            [
54
                [
55
                    'handle'
56
                ],
57
                'safe',
58
                'on' => [
59
                    ModelHelper::SCENARIO_DEFAULT
60
                ]
61
            ]
62
        ];
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function handleAttributeLabel()
69
    {
70
71
        return [
72
            'handle' => Craft::t('app', 'Handle')
73
        ];
74
    }
75
}
76