Delegate::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 2
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Loader\PathResolver;
5
6
use Innmind\Compose\{
7
    Loader\PathResolver,
8
    Exception\ValueNotSupported
9
};
10
use Innmind\Url\PathInterface;
11
12
final class Delegate implements PathResolver
13
{
14
    private $resolvers;
15
16 13
    public function __construct(PathResolver ...$resolvers)
17
    {
18 13
        $this->resolvers = $resolvers;
19 13
    }
20
21 9
    public function __invoke(PathInterface $from, PathInterface $to): PathInterface
22
    {
23 9
        foreach ($this->resolvers as $resolve) {
24
            try {
25 9
                return $resolve($from, $to);
26 9
            } catch (ValueNotSupported $e) {
27
                //pass
28
            }
29
        }
30
31 1
        throw new ValueNotSupported((string) $to);
32
    }
33
}
34