Delegate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 11 3
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