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

PathResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
dl 0
loc 20
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 5 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
    {
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