Test Failed
Push — master ( 894c40...e5d2d2 )
by Julien
11:34
created

SkippableTrait::enable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Mvc\Model\Behavior;
13
14
use Phalcon\Mvc\Model\Behavior;
15
use Phalcon\Mvc\ModelInterface;
16
17
/**
18
 * Allow to enable or disable trait
19
 */
20
trait SkippableTrait
21
{
22
    public bool $enabled = true;
23
    
24
    /**
25
     * Return true if the behavior is enabled
26
     * on the current model instance
27
     */
28
    public function getEnabled(): bool
29
    {
30
        return $this->enabled;
31
    }
32
    
33
    /**
34
     * Set true to enable the behavior
35
     * on the current model instance
36
     */
37
    public function setEnabled(bool $enabled): void
38
    {
39
        $this->enabled = $enabled;
40
    }
41
    
42
    /**
43
     * Enable the behavior
44
     * on the current model instance
45
     */
46
    public function enable(): void
47
    {
48
        $this->setEnabled(true);
49
    }
50
    
51
    /**
52
     * Disable the behavior
53
     * on the current model instance
54
     */
55
    public function disable(): void
56
    {
57
        $this->setEnabled(false);
58
    }
59
    
60
    /**
61
     * Return true if the behavior is enabled
62
     * on the current model instance
63
     */
64
    public function isEnabled(): bool
65
    {
66
        return $this->getEnabled();
67
    }
68
}
69