ModelWithId::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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