Completed
Pull Request — master (#15)
by
unknown
08:21
created

AndSpecification   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 41
ccs 6
cts 6
cp 1
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 canBeSatisfiedBySomethingBelow() 0 6 2
A willBeSatisfiedByEverythingBelow() 0 6 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
50
            self::thatCanBeSatisfiedBySomethingBelow($this->one, $value)
51
            && self::thatCanBeSatisfiedBySomethingBelow($this->other, $value);
52
    }
53
54
    /** @inheritDoc */
55
    public function willBeSatisfiedByEverythingBelow(array $value): bool
56
    {
57
        return
58
            self::thatWillBeSatisfiedByEverythingBelow($this->one, $value)
59
            && self::thatWillBeSatisfiedByEverythingBelow($this->other, $value);
60
    }
61
}
62