Completed
Push — develop ( 16e25e...7d2249 )
by Baptiste
01:52
created

Delegate::__construct()   A

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 1
Bugs 0 Features 1
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 1
b 0
f 1
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 8
    public function __construct(PathResolver ...$resolvers)
17
    {
18 8
        $this->resolvers = $resolvers;
19 8
    }
20
21 4
    public function __invoke(PathInterface $from, PathInterface $to): PathInterface
22
    {
23 4
        foreach ($this->resolvers as $resolve) {
24
            try {
25 4
                return $resolve($from, $to);
26 4
            } catch (ValueNotSupported $e) {
27
                //pass
28
            }
29
        }
30
31 1
        throw new ValueNotSupported((string) $to);
32
    }
33
}
34