EmberTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 69
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 3 1
A stateRules() 0 10 1
A tableAlias() 0 3 1
A toEnabled() 0 4 1
A tableName() 0 3 1
A isDisabled() 0 3 1
A toDisabled() 0 4 1
1
<?php
2
3
4
namespace flipbox\keychain\records;
5
6
7
use yii\base\Model;
8
9
/**
10
 * Trait Ember
11
 * @package flipbox\saml\core\records
12
 * @property bool $enabled
13
 */
14
trait EmberTrait
15
{
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public static function tableAlias()
21
    {
22
        return static::TABLE_ALIAS;
0 ignored issues
show
Bug introduced by
The constant flipbox\keychain\records\EmberTrait::TABLE_ALIAS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public static function tableName()
29
    {
30
        return '{{%' . static::tableAlias() . '}}';
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function stateRules()
37
    {
38
        return [
39
            [
40
                [
41
                    'enabled'
42
                ],
43
                'safe',
44
                'on' => [
45
                    Model::SCENARIO_DEFAULT
46
                ]
47
            ]
48
        ];
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function isEnabled()
55
    {
56
        return (bool)$this->enabled;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function isDisabled()
63
    {
64
        return !$this->isEnabled();
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function toEnabled()
71
    {
72
        $this->enabled = true;
73
        return $this;
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79
    public function toDisabled()
80
    {
81
        $this->enabled = false;
82
        return $this;
83
    }
84
}
85