AnyOf   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A append() 0 3 1
A isSatisfiedBy() 0 9 3
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