Completed
Pull Request — master (#15)
by
unknown
05:30
created

CompositeSpecification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 39
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A andSpecification() 0 4 1
A orSpecification() 0 4 1
A notSpecification() 0 4 1
A canBeSatisfiedByAnythingBelow() 0 4 1
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 CompositeSpecification
19
 * Base class for specifications, allows for combining specifications
20
 */
21
abstract class CompositeSpecification implements SpecificationInterface
22
{
23
    /**
24
     * Returns a specification that satisfies the original specification
25
     * as well as the other specification
26
     * @param SpecificationInterface $other
27 1
     * @return AndSpecification
28
     */
29 1
    public function andSpecification(SpecificationInterface $other): AndSpecification
30
    {
31
        return new AndSpecification($this, $other);
32
    }
33
34
    /**
35
     * Returns a specification that satisfies the original specification
36 1
     * or the other specification
37
     * @param SpecificationInterface $other
38 1
     * @return OrSpecification
39
     */
40
    public function orSpecification(SpecificationInterface $other): OrSpecification
41
    {
42
        return new OrSpecification($this, $other);
43
    }
44
45 1
    /**
46
     * Returns a specification that is the inverse of the original specification
47 1
     * i.e. does not meet the original criteria
48
     */
49
    public function notSpecification(): NotSpecification
50
    {
51
        return new NotSpecification($this);
52
    }
53
54
    /** @inheritDoc */
55
    public function canBeSatisfiedByAnythingBelow(array $value): bool
56
    {
57
        return true;
58
    }
59
}
60