AnyOfSpecification::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Anfischer\Specification;
5
6
class AnyOfSpecification 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 true;
30
            }
31
        }
32
33 2
        return false;
34
    }
35
}
36