Completed
Push — master ( d3e6cc...2f8137 )
by Damien
16:23 queued 06:10
created

Ember::toEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace flipbox\saml\core\records\traits;
5
6
use yii\base\Model;
7
8
/**
9
 * Trait Ember
10
 * @package flipbox\saml\core\records
11
 * @property bool $enabled
12
 */
13
trait Ember
14
{
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public static function tableAlias()
20
    {
21
        return static::TABLE_ALIAS;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public static function tableName()
28
    {
29
        return '{{%' . static::tableAlias() . '}}';
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function stateRules()
36
    {
37
        return [
38
            [
39
                [
40
                    'enabled'
41
                ],
42
                'safe',
43
                'on' => [
44
                    Model::SCENARIO_DEFAULT
45
                ]
46
            ]
47
        ];
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function isEnabled()
54
    {
55
        return (bool)$this->enabled;
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function isDisabled()
62
    {
63
        return !$this->isEnabled();
64
    }
65
66
    /**
67
     * @inheritdoc
68
     */
69
    public function toEnabled()
70
    {
71
        $this->enabled = true;
72
        return $this;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78
    public function toDisabled()
79
    {
80
        $this->enabled = false;
81
        return $this;
82
    }
83
}
84