Code Duplication    Length = 66-66 lines in 2 locations

src/elements/ElementWithHandle.php 1 location

@@ 19-84 (lines=66) @@
16
use craft\validators\HandleValidator;
17
use flipbox\spark\helpers\ElementHelper;
18
19
abstract class ElementWithHandle extends Element
20
{
21
22
    /**
23
     * @var string Handle
24
     */
25
    public $handle;
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function rules()
31
    {
32
33
        return array_merge(
34
            parent::rules(),
35
            [
36
                [
37
                    [
38
                        'handle'
39
                    ],
40
                    HandleValidator::class
41
                ],
42
                [
43
                    [
44
                        'handle'
45
                    ],
46
                    'required'
47
                ],
48
                [
49
                    [
50
                        'handle'
51
                    ],
52
                    'string',
53
                    'max' => 255
54
                ],
55
                [
56
                    [
57
                        'handle'
58
                    ],
59
                    'safe',
60
                    'on' => [
61
                        ElementHelper::SCENARIO_DEFAULT
62
                    ]
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
84
}
85

src/models/ModelWithHandle.php 1 location

@@ 18-83 (lines=66) @@
15
use craft\validators\HandleValidator;
16
use flipbox\spark\helpers\ModelHelper;
17
18
abstract class ModelWithHandle extends Model
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