Completed
Push — master ( 5163d9...817b84 )
by Mike
07:06 queued 11s
created

AndSpecification::canBeSatisfiedBySomethingBelow()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of phpDocumentor.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @link      http://phpdoc.org
12
 */
13
14
namespace Flyfinder\Specification;
15
16
/**
17
 * Class AndSpecification
18
 *
19
 * @psalm-immutable
20
 */
21
final class AndSpecification extends CompositeSpecification
22
{
23
    /** @var SpecificationInterface */
24
    private $one;
25
26
    /** @var SpecificationInterface */
27
    private $other;
28
29
    /**
30
     * Initializes the AndSpecification object
31
     */
32
    public function __construct(SpecificationInterface $one, SpecificationInterface $other)
33
    {
34
        $this->one   = $one;
35 2
        $this->other = $other;
36
    }
37 2
38 2
    /**
39 2
     * {@inheritDoc}
40
     */
41
    public function isSatisfiedBy(array $value) : bool
42
    {
43
        return $this->one->isSatisfiedBy($value) && $this->other->isSatisfiedBy($value);
44
    }
45
46 2
    /** {@inheritDoc} */
47
    public function canBeSatisfiedBySomethingBelow(array $value) : bool
48 2
    {
49
        return self::thatCanBeSatisfiedBySomethingBelow($this->one, $value)
50
            && self::thatCanBeSatisfiedBySomethingBelow($this->other, $value);
51
    }
52
53
    /** {@inheritDoc} */
54
    public function willBeSatisfiedByEverythingBelow(array $value) : bool
55
    {
56
        return self::thatWillBeSatisfiedByEverythingBelow($this->one, $value)
57
            && self::thatWillBeSatisfiedByEverythingBelow($this->other, $value);
58
    }
59
}
60