Passed
Push — develop ( 4c2948...465d0d )
by Daniel
05:47
created

PathResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

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