AllOfSpecification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Anfischer\Specification;
5
6
class AllOfSpecification 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