Completed
Pull Request — master (#15)
by
unknown
03:57
created

OrSpecification   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 48
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isSatisfiedBy() 0 4 2
A canBeSatisfiedByAnythingBelow() 0 6 2
A willBeSatisfiedByEverythingBelow() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @copyright 2010-2018 Mike van Riel<[email protected]>
11
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
12
 * @link      http://phpdoc.org
13
 */
14
15
namespace Flyfinder\Specification;
16
17
/**
18
 * Class OrSpecification
19
 */
20
final class OrSpecification extends CompositeSpecification
21
{
22
    /**
23
     * @var SpecificationInterface
24
     */
25
    private $one;
26
27
    /**
28
     * @var SpecificationInterface
29
     */
30
    private $other;
31
32
    /**
33
     * Initializes the OrSpecification object
34
     */
35 2
    public function __construct(SpecificationInterface $one, SpecificationInterface $other)
36
    {
37 2
        $this->one = $one;
38 2
        $this->other = $other;
39 2
    }
40
41
    /**
42
     * Checks if the value meets the specification
43
     *
44
     * @param mixed[] $value
45
     * @return bool
46
     */
47 2
    public function isSatisfiedBy(array $value): bool
48
    {
49 2
        return $this->one->isSatisfiedBy($value) || $this->other->isSatisfiedBy($value);
50
    }
51
52
    /** @inheritDoc */
53
    public function canBeSatisfiedByAnythingBelow(array $value): bool
54
    {
55
        return
56
            self::thatCanBeSatisfiedByAnythingBelow($this->one, $value)
57
            || self::thatCanBeSatisfiedByAnythingBelow($this->other, $value);
58
    }
59
60
    /** @inheritDoc */
61
    public function willBeSatisfiedByEverythingBelow(array $value): bool
62
    {
63
        return
64
            self::thatWillBeSatisfiedByEverythingBelow($this->one, $value)
65
            || self::thatWillBeSatisfiedByEverythingBelow($this->other, $value);
66
    }
67
}
68