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

PathResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

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