RecordWithHandle   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 61
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 61
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

1 Method

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