Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
20 / 20 |
|
80.00% |
4 / 5 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| InvalidTypeCoercion | |
100.00% |
20 / 20 |
|
80.00% |
4 / 5 |
|
66.67% |
2 / 3 |
|
100.00% |
2 / 2 |
3.33 | |
100.00% |
1 / 1 |
| forContext | |
100.00% |
11 / 11 |
|
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| constructorFailure | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Quma\Exception; |
| 6 | |
| 7 | use Celemas\Quma\Hydration\HydrationContext; |
| 8 | use Throwable; |
| 9 | |
| 10 | /** @api */ |
| 11 | final class InvalidTypeCoercion extends HydrationFailure |
| 12 | { |
| 13 | /** @internal */ |
| 14 | public static function forContext( |
| 15 | HydrationContext $context, |
| 16 | mixed $value, |
| 17 | string $type, |
| 18 | string $reason, |
| 19 | ): self { |
| 20 | return new self(self::message( |
| 21 | $context->class, |
| 22 | $context->sourcePath, |
| 23 | "could not coerce column '{$context->column}' for parameter '\${$context->parameter}' to {$type}; " |
| 24 | . 'value type: ' |
| 25 | . self::valueType($value) |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 27 | . '. Row keys: ' |
| 28 | . self::formatRowKeys($context->rowKeys) |
| 29 | . '.', |
| 30 | )); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @param class-string $class |
| 35 | * @param list<string> $rowKeys |
| 36 | */ |
| 37 | public static function constructorFailure( |
| 38 | string $class, |
| 39 | ?string $sourcePath, |
| 40 | array $rowKeys, |
| 41 | Throwable $previous, |
| 42 | ): self { |
| 43 | return new self( |
| 44 | self::message( |
| 45 | $class, |
| 46 | $sourcePath, |
| 47 | 'constructor rejected hydrated arguments. Row keys: ' . self::formatRowKeys($rowKeys) . '.', |
| 48 | ), |
| 49 | 0, |
| 50 | $previous, |
| 51 | ); |
| 52 | } |
| 53 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 38 | string $class, |
| 39 | ?string $sourcePath, |
| 40 | array $rowKeys, |
| 41 | Throwable $previous, |
| 42 | ): self { |
| 43 | return new self( |
| 44 | self::message( |
| 45 | $class, |
| 46 | $sourcePath, |
| 47 | 'constructor rejected hydrated arguments. Row keys: ' . self::formatRowKeys($rowKeys) . '.', |
| 48 | ), |
| 49 | 0, |
| 50 | $previous, |
| 51 | ); |
| 52 | } |
| 15 | HydrationContext $context, |
| 16 | mixed $value, |
| 17 | string $type, |
| 18 | string $reason, |
| 19 | ): self { |
| 20 | return new self(self::message( |
| 21 | $context->class, |
| 22 | $context->sourcePath, |
| 23 | "could not coerce column '{$context->column}' for parameter '\${$context->parameter}' to {$type}; " |
| 24 | . 'value type: ' |
| 25 | . self::valueType($value) |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 27 | . '. Row keys: ' |
| 28 | . self::formatRowKeys($context->rowKeys) |
| 29 | . '.', |
| 30 | )); |
| 31 | } |
| 15 | HydrationContext $context, |
| 16 | mixed $value, |
| 17 | string $type, |
| 18 | string $reason, |
| 19 | ): self { |
| 20 | return new self(self::message( |
| 21 | $context->class, |
| 22 | $context->sourcePath, |
| 23 | "could not coerce column '{$context->column}' for parameter '\${$context->parameter}' to {$type}; " |
| 24 | . 'value type: ' |
| 25 | . self::valueType($value) |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 26 | . ($reason === '' ? '' : "; {$reason}") |
| 27 | . '. Row keys: ' |
| 28 | . self::formatRowKeys($context->rowKeys) |
| 29 | . '.', |
| 30 | )); |
| 31 | } |