BooleanEnsurance   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isTrue() 0 6 1
A isFalse() 0 6 1
1
<?php
2
3
namespace Dgame\Ensurance;
4
5
/**
6
 * Class BooleanEnsurance
7
 * @package Dgame\Ensurance
8
 */
9
final class BooleanEnsurance implements EnsuranceInterface
10
{
11
    use EnsuranceTrait;
12
13
    /**
14
     * BooleanEnsurance constructor.
15
     *
16
     * @param EnsuranceInterface $ensurance
17
     */
18
    public function __construct(EnsuranceInterface $ensurance)
19
    {
20
        $this->transferEnsurance($ensurance);
21
    }
22
23 2
    /**
24
     * @return BooleanEnsurance
25 2
     */
26 2
    public function isTrue(): self
27
    {
28
        $this->ensure($this->value)->orThrow('The value is not true');
29
30
        return $this;
31 1
    }
32
33 1
    /**
34
     * @return BooleanEnsurance
35 1
     */
36
    public function isFalse(): self
37
    {
38
        $this->ensure(!$this->value)->orThrow('The value is true');
39
40
        return $this;
41
    }
42
}