Boolean::onView()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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