SwitchState::isDisabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the ddd-common.
5
 *
6
 * Copyright 2021 Evgenii Dudal <[email protected]>.
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 * @package ddd-common
11
 */
12
13
namespace RobotE13\DDD\Entities\Status;
14
15
/**
16
 * Description of SwitchState
17
 *
18
 * @author Evgenii Dudal <[email protected]>
19
 */
20
final class SwitchState extends AbstractState
21
{
22
23
    const ENABLED = 1;
24
    const DISABLED = 0;
25
26 1
    public function enable()
27
    {
28 1
        $this->setState(static::ENABLED);
29 1
    }
30
31 1
    public function disable()
32
    {
33 1
        $this->setState(static::DISABLED);
34 1
    }
35
36 2
    public function isEnabled()
37
    {
38 2
        return $this->getState() === static::ENABLED;
39
    }
40
41 2
    public function isDisabled()
42
    {
43 2
        return $this->getState() === static::DISABLED;
44
    }
45
46 3
    public function getAllExisting(): array
47
    {
48
        return[
49 3
            static::ENABLED => 'Enabled',
50 3
            static::DISABLED => 'Disabled'
51
        ];
52
    }
53
54
}
55