Delegate::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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