Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
18 / 18 |
|
100.00% |
12 / 12 |
|
100.00% |
9 / 9 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Review | |
100.00% |
18 / 18 |
|
100.00% |
12 / 12 |
|
100.00% |
9 / 9 |
|
100.00% |
6 / 6 |
10 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addError | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isList | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| values | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| path | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
4 | |||
| normalizePath | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Sire; |
| 6 | |
| 7 | /** @api */ |
| 8 | final readonly class Review |
| 9 | { |
| 10 | public function __construct( |
| 11 | private ErrorBag $errors, |
| 12 | private array $values, |
| 13 | private bool $list, |
| 14 | ) {} |
| 15 | |
| 16 | /** |
| 17 | * @param string|int|list<string|int> $path |
| 18 | * @param array<string, mixed> $params |
| 19 | */ |
| 20 | public function addError( |
| 21 | string|int|array $path, |
| 22 | string $message, |
| 23 | string $code = 'custom', |
| 24 | array $params = [], |
| 25 | ): void { |
| 26 | $this->errors->add( |
| 27 | self::path($path), |
| 28 | new Issue([], $code, $message, $params), |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | public function isList(): bool |
| 33 | { |
| 34 | return $this->list; |
| 35 | } |
| 36 | |
| 37 | /** @return array<array-key, mixed> */ |
| 38 | public function values(): array |
| 39 | { |
| 40 | return $this->values; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @param string|int|list<string|int> $path |
| 45 | * @return list<string|int> |
| 46 | */ |
| 47 | private static function path(string|int|array $path): array |
| 48 | { |
| 49 | if (is_int($path)) { |
| 50 | return [$path]; |
| 51 | } |
| 52 | |
| 53 | if (is_string($path)) { |
| 54 | if ($path === '') { |
| 55 | return []; |
| 56 | } |
| 57 | |
| 58 | return self::normalizePath(explode('.', $path)); |
| 59 | } |
| 60 | |
| 61 | return $path; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @param list<string> $path |
| 66 | * @return list<string|int> |
| 67 | */ |
| 68 | private static function normalizePath(array $path): array |
| 69 | { |
| 70 | return array_map( |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |
| 72 | $path, |
| 73 | ); |
| 74 | } |
| 75 | } |
Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not
necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once.
Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 11 | private ErrorBag $errors, |
| 12 | private array $values, |
| 13 | private bool $list, |
| 14 | ) {} |
| 21 | string|int|array $path, |
| 22 | string $message, |
| 23 | string $code = 'custom', |
| 24 | array $params = [], |
| 25 | ): void { |
| 26 | $this->errors->add( |
| 27 | self::path($path), |
| 28 | new Issue([], $code, $message, $params), |
| 29 | ); |
| 30 | } |
| 34 | return $this->list; |
| 35 | } |
| 68 | private static function normalizePath(array $path): array |
| 69 | { |
| 70 | return array_map( |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |
| 72 | $path, |
| 73 | ); |
| 74 | } |
| 47 | private static function path(string|int|array $path): array |
| 48 | { |
| 49 | if (is_int($path)) { |
| 50 | return [$path]; |
| 53 | if (is_string($path)) { |
| 54 | if ($path === '') { |
| 55 | return []; |
| 58 | return self::normalizePath(explode('.', $path)); |
| 61 | return $path; |
| 62 | } |
| 40 | return $this->values; |
| 41 | } |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |
| 71 | static fn(string $part): string|int => ctype_digit($part) ? (int) $part : $part, |