Passed
Push — master ( 39c748...16551a )
by Nate
06:42
created

ModelWithHandle::rules()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 14

Duplication

Lines 38
Ratio 100 %

Importance

Changes 0
Metric Value
dl 38
loc 38
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package    Spark
5
 * @author     Flipbox Factory <[email protected]>
6
 * @copyright  2010-2016 Flipbox Digital Limited
7
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
8
 * @link       https://github.com/flipbox/spark
9
 * @since      Class available since Release 1.0.0
10
 */
11
12
namespace flipbox\spark\models;
13
14
use Craft;
15
use craft\validators\HandleValidator;
16
use flipbox\spark\helpers\ModelHelper;
17
18 View Code Duplication
abstract class ModelWithHandle extends Model
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
21
    /**
22
     * @var string Handle
23
     */
24
    public $handle;
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function rules()
30
    {
31
32
        return array_merge(
33
            parent::rules(),
34
            [
35
                [
36
                    [
37
                        'handle'
38
                    ],
39
                    HandleValidator::class
40
                ],
41
                [
42
                    [
43
                        'handle'
44
                    ],
45
                    'required'
46
                ],
47
                [
48
                    [
49
                        'handle'
50
                    ],
51
                    'string',
52
                    'max' => 255
53
                ],
54
                [
55
                    [
56
                        'handle'
57
                    ],
58
                    'safe',
59
                    'on' => [
60
                        ModelHelper::SCENARIO_DEFAULT
61
                    ]
62
                ]
63
            ]
64
        );
65
66
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71
    public function attributeLabels()
72
    {
73
74
        return array_merge(
75
            parent::attributeLabels(),
76
            [
77
                'handle' => Craft::t('app', 'Handle')
78
            ]
79
        );
80
81
    }
82
83
}
84