AndSpecification   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 30
loc 30
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A isSatisfiedBy() 4 4 2

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 AndSpecification extends Specification
6
{
7
    /**
8
     * @var Specification
9
     */
10
    private $one;
11
12
    /**
13
     * @var Specification
14
     */
15
    private $other;
16
17
    /**
18
     * @param Specification $one
19
     * @param Specification $other
20
     */
21 1
    public function __construct(Specification $one, Specification $other)
22
    {
23 1
        $this->one   = $one;
24 1
        $this->other = $other;
25 1
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 1
    public function isSatisfiedBy($object): bool
31
    {
32 1
        return $this->one->isSatisfiedBy($object) && $this->other->isSatisfiedBy($object);
33
    }
34
}
35