OrX::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GBProd\Specification;
6
7
/**
8
 * Or specification implementation
9
 *
10
 * @author gbprod <[email protected]>
11
 */
12 View Code Duplication
final class OrX extends CompositeSpecification
0 ignored issues
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...
13
{
14
    /**
15
     * @var Specification
16
     */
17
    private $firstPart;
18
19
    /**
20
     * @var Specification
21
     */
22
    private $secondPart;
23
24
    /**
25
     * @param Specification $firstPart
26
     * @param Specification $secondPart
27
     */
28 7
    public function __construct(Specification $firstPart, Specification $secondPart)
29
    {
30 7
        $this->firstPart = $firstPart;
31 7
        $this->secondPart = $secondPart;
32 7
    }
33
34
    /**
35
     * {inheritdoc}
36
     */
37 5
    public function isSatisfiedBy($candidate): bool
38
    {
39 5
        return $this->firstPart->isSatisfiedBy($candidate)
40 5
            || $this->secondPart->isSatisfiedBy($candidate)
41
        ;
42
    }
43
44
    /**
45
     * Get the first part of the condition
46
     *
47
     * @return Specification
48
     */
49 1
    public function getFirstPart(): Specification
50
    {
51 1
        return $this->firstPart;
52
    }
53
54
    /**
55
     * Get the second part of the condition
56
     *
57
     * @return Specification
58
     */
59 1
    public function getSecondPart(): Specification
60
    {
61 1
        return $this->secondPart;
62
    }
63
}
64