Completed
Push — master ( 9d6b90...0a141c )
by Randy
11:08
created

BooleanExpectations::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Dgame\Expectation;
4
5
/**
6
 * Class BooleanExpectations
7
 * @package Dgame\Expectation
8
 */
9
final class BooleanExpectations extends ScalarExpectations
10
{
11
    /**
12
     * BooleanExpectations constructor.
13
     *
14
     * @param $value
15
     */
16
    public function __construct($value)
17
    {
18
        if ($this->isBool($value)) {
19
            parent::__construct($value);
20
        }
21
    }
22
23
    /**
24
     * @param $value
25
     *
26
     * @return bool
27
     */
28
    private function isBool($value): bool
29
    {
30
        return $this->approveIf(is_bool($value))->isApproved();
31
    }
32
33
    /**
34
     * @return BooleanExpectations
35
     */
36
    public function isTrue(): self
37
    {
38
        return $this->approveIf($this->value === true);
39
    }
40
41
    /**
42
     * @return BooleanExpectations
43
     */
44
    public function isFalse(): self
45
    {
46
        return $this->approveIf($this->value === false);
47
    }
48
}