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

PathResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 8 3
A __construct() 0 4 1
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