| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 6 | public function __invoke(PathInterface $from, PathInterface $to): PathInterface |
|
| 20 | { |
||
| 21 | 6 | $target = Str::of((string) $to); |
|
| 22 | |||
| 23 | 6 | if ((string) $target->substring(0, 1) === '/') { |
|
| 24 | 1 | return $to; |
|
| 25 | } |
||
| 26 | |||
| 27 | 5 | $origin = Str::of((string) $from); |
|
| 28 | 5 | $toRemove = 0; |
|
| 29 | |||
| 30 | 5 | if ((string) $origin->substring(0, 1) !== '/') { |
|
| 31 | 5 | $origin = $origin->prepend('/'); |
|
| 32 | 5 | ++$toRemove; |
|
| 33 | } |
||
| 34 | |||
| 35 | 5 | $target = (new ResolverPath((string) $origin))->pointingTo( |
|
| 36 | 5 | new RelativePath((string) $to) |
|
| 37 | ); |
||
| 38 | |||
| 39 | 5 | return new Path( |
|
| 40 | 5 | (string) Str::of((string) $target)->substring($toRemove) |
|
| 41 | ); |
||
| 44 |