AnyOf::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace FlexFqcnFinder\Filter\Specifications;
5
6
use FlexFqcnFinder\Filter\Chainable;
7
use FlexFqcnFinder\Filter\FqcnSpecification;
8
9
/**
10
 * 'OR' operator
11
 */
12
class AnyOf implements FqcnSpecification, Chainable
13
{
14
    /**
15
     * @var FqcnSpecification[]
16
     */
17
    protected $specifications;
18
19
    public function __construct(FqcnSpecification $specification, FqcnSpecification ...$specifications)
20
    {
21
        $this->specifications = $specifications;
22
        $this->append($specification);
23
    }
24
25
    public function isSatisfiedBy(string $fqcn): bool
26
    {
27
        foreach ($this->specifications as $fqcnSpecification) {
28
            if ($fqcnSpecification->isSatisfiedBy($fqcn)) {
29
                return true;
30
            }
31
        }
32
33
        return false;
34
    }
35
36
    public function append(FqcnSpecification $specification)
37
    {
38
        $this->specifications[] = $specification;
39
    }
40
}
41