Passed
Push — develop ( 185343...eb895f )
by Daniel
06:30
created

PathResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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 3
        $this->roots = $roots;
14 3
    }
15
16 1
    public function resolve($path):string
17
    {
18 1
        foreach ($this->roots as $root) {
19 1
            if (mb_strpos($path, $root) === 0) {
20 1
                return mb_substr($path, \strlen($root));
21
            }
22
        }
23
        return $path;
24
    }
25
}
26