Completed
Push — master ( 062b68...81f5ad )
by Terzi
08:48
created

Boolean::isTrue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Terranet\Administrator\Field;
4
5
class Boolean extends Generic
6
{
7
    /** @var mixed */
8
    protected $trueValue = 1;
9
10
    /** @var mixed */
11
    protected $falseValue = 0;
12
13
    /**
14
     * @param $value
15
     * @return $this
16
     */
17
    public function trueValue($value)
18
    {
19
        $this->trueValue = $value;
20
21
        return $this;
22
    }
23
24
    /**
25
     * @param $value
26
     * @return $this
27
     */
28
    public function falseValue($value)
29
    {
30
        $this->falseValue = $value;
31
32
        return $this;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isTrue()
39
    {
40
        return $this->value() === $this->trueValue;
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    public function onIndex()
47
    {
48
        return ['isTrue' => $this->isTrue()];
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function onView()
55
    {
56
        return $this->onIndex();
57
    }
58
}
59