BooleanExpectations::isTrue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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 mixed $value
15
     */
16 3
    public function __construct($value)
17
    {
18 3
        if ($this->isBool($value)) {
19 3
            parent::__construct($value);
20
        }
21 3
    }
22
23
    /**
24
     * @param mixed $value
25
     *
26
     * @return bool
27
     */
28 3
    private function isBool($value): bool
29
    {
30 3
        return $this->approveIf(is_bool($value))->isApproved();
31
    }
32
33
    /**
34
     * @return BooleanExpectations
35
     */
36 1
    public function isTrue(): self
37
    {
38 1
        return $this->approveIf($this->value === true);
39
    }
40
41
    /**
42
     * @return BooleanExpectations
43
     */
44 1
    public function isFalse(): self
45
    {
46 1
        return $this->approveIf($this->value === false);
47
    }
48
}
49