Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
11 / 11 |
|
85.71% |
24 / 28 |
|
2.76% |
9 / 326 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Util | |
100.00% |
11 / 11 |
|
85.71% |
24 / 28 |
|
2.76% |
9 / 326 |
|
100.00% |
2 / 2 |
83.47 | |
100.00% |
1 / 1 |
| assertPathSegment | |
100.00% |
8 / 8 |
|
84.00% |
21 / 25 |
|
2.16% |
7 / 324 |
|
100.00% |
1 / 1 |
52.89 | |||
| isAssoc | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Quma; |
| 6 | |
| 7 | use RuntimeException; |
| 8 | |
| 9 | final class Util |
| 10 | { |
| 11 | public static function assertPathSegment(string $segment, string $label): void |
| 12 | { |
| 13 | if ( |
| 14 | $segment === '' |
| 15 | || $segment === '.' |
| 16 | || $segment === '..' |
| 17 | || str_contains($segment, '/') |
| 18 | || str_contains($segment, '\\') |
| 19 | || str_contains($segment, "\0") |
| 20 | ) { |
| 21 | $display = str_replace("\0", '\\0', $segment); |
| 22 | |
| 23 | throw new RuntimeException("Invalid {$label}: {$display}"); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | public static function isAssoc(array $arr): bool |
| 28 | { |
| 29 | if ([] === $arr) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | return array_keys($arr) !== range(0, count($arr) - 1); |
| 34 | } |
| 35 | } |