Completed
Push — master ( 0be8e1...585ca2 )
by Daniel
59:26 queued 46:02
created

PathResolver::resolve()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Silverback\ApiComponentBundle\Imagine;
6
7
class PathResolver
8
{
9
    /** @var array */
10
    private $roots;
11
12
    public function __construct(
13
        array $roots = []
14
    ) {
15
        $this->roots = $roots;
16
    }
17
18
    public function resolve($path): string
19
    {
20
        foreach ($this->roots as $root) {
21
            if (mb_strpos($path, $root) === 0) {
22
                return mb_substr($path, \strlen($root));
23
            }
24
        }
25
        return $path;
26
    }
27
}
28