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

NotSpecification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 32
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isSatisfiedBy() 0 4 1
A canBeSatisfiedByAnythingBelow() 0 4 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 NotSpecification
19
 */
20
final class NotSpecification extends CompositeSpecification
21
{
22
    /**
23
     * @var SpecificationInterface
24
     */
25
    private $wrapped;
26
27
    /**
28
     * Initializes the NotSpecification object
29
     */
30 2
    public function __construct(SpecificationInterface $wrapped)
31
    {
32 2
        $this->wrapped = $wrapped;
33 2
    }
34
35
    /**
36
     * Checks if the value meets the specification
37
     *
38
     * @param mixed[] $value
39
     * @return bool
40
     */
41 2
    public function isSatisfiedBy(array $value): bool
42
    {
43 2
        return !$this->wrapped->isSatisfiedBy($value);
44
    }
45
46
    /** @inheritDoc */
47
    public function canBeSatisfiedByAnythingBelow(array $value): bool
48
    {
49
        return !($this->wrapped instanceof InPath) || !$this->wrapped->isSatisfiedBy($value);
50
    }
51
}
52