InteractorProxyTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 29
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CCT\Component\Collections\Traits;
6
7
use CCT\Component\Collections\CollectionProxy;
8
9
trait InteractorProxyTrait
10
{
11
    /**
12
     * Gets the possible proxies for the class.
13
     *
14
     * @return array
15
     */
16
    protected abstract function getInteractorProxies(): array;
17
18
    /**
19
     * Dynamically access collection proxies.
20
     *
21
     * @param string $proxy
22
     * @param mixed $args
23
     *
24
     * @return CollectionProxy
25
     *
26
     * @throws \Exception
27
     */
28 13
    public function __call($proxy, $args = null)
29
    {
30 13
        $possibleProxies = CollectionProxy::$proxies;
31 13
        $proxies = array_intersect($possibleProxies, $this->getInteractorProxies());
32
33 13
        if (false === array_key_exists($proxy, $proxies)) {
34 1
            throw new \BadMethodCallException("Method [{$proxy}] does not exist on this collection instance.");
35
        }
36
37 12
        return new CollectionProxy($this, $proxy);
0 ignored issues
show
Bug introduced by
$this of type CCT\Component\Collection...ts\InteractorProxyTrait is incompatible with the type CCT\Component\Collections\CollectionInterface expected by parameter $collection of CCT\Component\Collection...ionProxy::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return new CollectionProxy(/** @scrutinizer ignore-type */ $this, $proxy);
Loading history...
38
    }
39
}
40