ModelWithId   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A idRules() 0 22 1
A idAttributeLabel() 0 7 1
A getId() 0 4 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 flipbox\spark\helpers\ModelHelper;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
trait ModelWithId
19
{
20
21
    /**
22
     * @var integer
23
     */
24
    public $id;
25
26
    /**
27
     * @inheritdoc
28
     */
29
    protected function idRules()
30
    {
31
32
        return [
33
            [
34
                [
35
                    'id'
36
                ],
37
                'number',
38
                'integerOnly' => true
39
            ],
40
            [
41
                [
42
                    'id'
43
                ],
44
                'safe',
45
                'on' => [
46
                    ModelHelper::SCENARIO_DEFAULT
47
                ]
48
            ]
49
        ];
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    protected function idAttributeLabel()
56
    {
57
58
        return [
59
            'id' => Craft::t('app', 'Id')
60
        ];
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
}
71