FqcnSpecificationChain   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 4 1
A isSatisfiedBy() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace FlexFqcnFinder\Filter;
5
6
use Closure;
7
8
/**
9
 * @method self apply(Closure $fn)
10
 * @method self alwaysTrue()
11
 * @method self alwaysFalse()
12
 * @method self belongsToNamespace(string $namespace)
13
 * @method self classNameEndsWith(string $value)
14
 * @method self classNameStartsWith(string $value)
15
 * @method self hasMethod(string $method)
16
 * @method self implementsInterface(string $interface)
17
 * @method self isAbstract()
18
 * @method self isClass()
19
 * @method self isCloneable()
20
 * @method self isFinal()
21
 * @method self isInstanceOf(string $subject)
22
 * @method self isInstantiable()
23
 * @method self isInterface()
24
 * @method self isInternal()
25
 * @method self isIterateable()
26
 * @method self isSubClassOf(string $class)
27
 * @method self isTrait()
28
 * @method self isUserDefined()
29
 * @method self namespaceEqualsTo(string $namespace)
30
 * @method self not(FqcnSpecification $specification)
31
 * @method self useTrait(string $trait)
32
 * @method self anyOf(FqcnSpecification $specification, FqcnSpecification ...$specifications)
33
 * @method self allOf(FqcnSpecification $specification, FqcnSpecification ...$specifications)
34
 * @method self and(FqcnSpecification $specification, FqcnSpecification ...$specifications)
35
 * @method self or(FqcnSpecification $specification, FqcnSpecification ...$specifications)
36
 */
37
final class FqcnSpecificationChain implements FqcnSpecification
38
{
39
    /**
40
     * @var Chainable
41
     */
42
    private $chain;
43
44
    /**
45
     * @var FqcnSpecificationFactory
46
     */
47
    private $fqcnSpecificationFactory;
48
49
    public function __construct(Chainable $chain)
50
    {
51
        $this->chain = $chain;
52
        $this->fqcnSpecificationFactory = new FqcnSpecificationFactory();
53
    }
54
55
    public function isSatisfiedBy(string $fqcn): bool
56
    {
57
        return $this->chain->isSatisfiedBy($fqcn);
58
    }
59
60
    public function __call($name, $arguments)
61
    {
62
        $this->chain->append($this->fqcnSpecificationFactory->{$name}(...$arguments));
63
        return $this;
64
    }
65
}
66