Total Complexity | 8 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 22.22% |
Changes | 0 |
1 | <?php |
||
7 | class BaseUrlSegment |
||
8 | { |
||
9 | /** |
||
10 | * @param ProvidesUrl $model |
||
11 | * @param string $slug |
||
12 | * @param $locale |
||
13 | * @return string |
||
14 | */ |
||
15 | 72 | public static function prepend(ProvidesUrl $model, string $slug, $locale): string |
|
23 | } |
||
24 | |||
25 | public static function strip($value) |
||
26 | { |
||
27 | $originalValue = $value = trim($value, '/'); |
||
28 | |||
29 | $segments = static::all(); |
||
30 | |||
31 | foreach ($segments as $segment) { |
||
32 | if (0 === strpos($originalValue, $segment)) { |
||
33 | $value = substr($value, strlen($segment)); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return trim($value, '/'); |
||
38 | } |
||
39 | |||
40 | private static function all(): array |
||
53 | } |
||
54 | } |
||
55 |