BooleanSpecification   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A validate() 0 6 2
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