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

AndSpecification::canBeSatisfiedByAnythingBelow()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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 AndSpecification
19
 */
20
final class AndSpecification 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 AndSpecification object
34
     * @param SpecificationInterface $one
35
     * @param SpecificationInterface $other
36
     */
37 2
    public function __construct(SpecificationInterface $one, SpecificationInterface $other)
38
    {
39 2
        $this->one = $one;
40 2
        $this->other = $other;
41 2
    }
42
43
    /**
44
     * Checks if the value meets the specification
45
     *
46
     * @param mixed[] $value
47
     * @return bool
48
     */
49 2
    public function isSatisfiedBy(array $value): bool
50
    {
51 2
        return $this->one->isSatisfiedBy($value) && $this->other->isSatisfiedBy($value);
52
    }
53
54
    /** @inheritDoc */
55
    public function canBeSatisfiedByAnythingBelow(array $value): bool
56
    {
57
        return
58
            $this->one->canBeSatisfiedByAnythingBelow($value)
59
            && $this->other->canBeSatisfiedByAnythingBelow($value);
60
    }
61
62
63
}
64