| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 50 | public function getPathSegment(int $index): string |
||
| 51 | { |
||
| 52 | if ($index < 0) { |
||
| 53 | throw new EnsureException('Index must not be negative'); |
||
| 54 | } |
||
| 55 | $path = parse_url($this->value, PHP_URL_PATH); |
||
| 56 | $parts = explode('/', trim($path, '/')); |
||
| 57 | if (count($parts) <= $index) { |
||
| 58 | throw new UriException(sprintf('URI does not have %d segments', $index)); |
||
| 59 | } |
||
| 60 | return $parts[$index]; |
||
| 61 | } |
||
| 62 | |||
| 64 |