BooleanSpecification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace BenTools\Specification\Helper;
4
5
use BenTools\Specification\Specification;
6
use function BenTools\Specification\reject;
7
8
final class BooleanSpecification extends Specification
9
{
10
    /**
11
     * @var bool
12
     */
13
    private $bool;
14
15
    /**
16
     * BooleanSpecification constructor.
17
     *
18
     * @param bool        $bool
19
     * @param null|string $name
20
     */
21
    protected function __construct(bool $bool, ?string $name)
22
    {
23
        $this->bool = $bool;
24
        $this->label = $name;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function validate(): void
31
    {
32
        if (false === $this->bool) {
33
            reject($this);
34
        }
35
    }
36
}
37