NoneOfSpecification   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isSatisfiedBy() 0 9 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Anfischer\Specification;
5
6
class NoneOfSpecification extends Specification
7
{
8
    /**
9
     * @var Specification[]
10
     */
11
    private $specifications;
12
13
    /**
14
     * @param Specification[] $specifications
15
     */
16 2
    public function __construct(Specification ...$specifications)
17
    {
18 2
        $this->specifications = $specifications;
19 2
    }
20
21
    /**
22
     * @param mixed $object
23
     * @return bool
24
     */
25 2
    public function isSatisfiedBy($object): bool
26
    {
27 2
        foreach ($this->specifications as $specification) {
28 2
            if ($specification->isSatisfiedBy($object)) {
29 2
                return false;
30
            }
31
        }
32
33 2
        return true;
34
    }
35
}
36