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

AnyOfSpecification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A isSatisfiedBy() 10 10 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}