Passed
Branch master (439dc1)
by Hirofumi
02:30
created

AnyOfSpecification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Tanigami\Specification;
4
5 View Code Duplication
class AnyOfSpecification
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    /**
8
     * @var Specification[]
9
     */
10
    private $specifications;
11
12
    /**
13
     * @param Specification[] ...$specifications
14
     */
15 1
    public function __construct(Specification ...$specifications)
16
    {
17 1
        $this->specifications = $specifications;
1 ignored issue
show
Documentation Bug introduced by
It seems like $specifications of type array<integer,array<inte...cation\Specification>>> is incompatible with the declared type array<integer,object<Tan...ication\Specification>> of property $specifications.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
18 1
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function isSatisfiedBy($object): bool
24
    {
25 1
        foreach ($this->specifications as $specification) {
26 1
            if (!$specification->isSatisfiedBy($object)) {
27 1
                return false;
28
            }
29
        }
30
31 1
        return true;
32
    }
33
}