HandleRulesTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 0
dl 0
loc 53
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleRules() 0 34 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipboxfactory/craft-ember/blob/master/LICENSE
6
 * @link       https://github.com/flipboxfactory/craft-ember/
7
 */
8
9
namespace flipbox\craft\ember\models;
10
11
use craft\validators\HandleValidator;
12
use yii\base\Model;
13
14
/**
15
 * @property string|null $handle
16
 *
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 2.0.0
19
 */
20
trait HandleRulesTrait
21
{
22
    /**
23
     * @var array
24
     */
25
    protected $reservedHandleWords = [
26
        'id',
27
        'uid',
28
    ];
29
30
    /**
31
     * @var int
32
     */
33
    protected $handleLength = 150;
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function handleRules()
39
    {
40
        return [
41
            [
42
                [
43
                    'handle'
44
                ],
45
                HandleValidator::class,
46
                'reservedWords' => $this->reservedHandleWords
47
            ],
48
            [
49
                [
50
                    'handle'
51
                ],
52
                'required'
53
            ],
54
            [
55
                [
56
                    'handle'
57
                ],
58
                'string',
59
                'max' => $this->handleLength
60
            ],
61
            [
62
                [
63
                    'handle'
64
                ],
65
                'safe',
66
                'on' => [
67
                    Model::SCENARIO_DEFAULT
68
                ]
69
            ]
70
        ];
71
    }
72
}
73