Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
7 / 7 |
|
66.67% |
4 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| InvalidHydrationTarget | |
100.00% |
16 / 16 |
|
100.00% |
7 / 7 |
|
66.67% |
4 / 6 |
|
100.00% |
3 / 3 |
5.93 | |
100.00% |
1 / 1 |
| forTarget | |
100.00% |
6 / 6 |
|
100.00% |
5 / 5 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
4.12 | |||
| forParameter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| forClosureResult | |
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 Throwable; |
| 8 | |
| 9 | /** @api */ |
| 10 | final class InvalidHydrationTarget extends HydrationFailure |
| 11 | { |
| 12 | /** @param list<string> $rowKeys */ |
| 13 | public static function forTarget( |
| 14 | string $target, |
| 15 | ?string $sourcePath = null, |
| 16 | array $rowKeys = [], |
| 17 | string $reason = '', |
| 18 | ?Throwable $previous = null, |
| 19 | ): self { |
| 20 | $message = "Invalid hydration target '{$target}' from " . self::source($sourcePath); |
| 21 | |
| 22 | if ($reason !== '') { |
| 23 | $message .= ": {$reason}"; |
| 24 | } |
| 25 | |
| 26 | if ($rowKeys !== []) { |
| 27 | $message .= '. Row keys: ' . self::formatRowKeys($rowKeys); |
| 28 | } |
| 29 | |
| 30 | return new self($message . '.', 0, $previous); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @param class-string $class |
| 35 | * @param non-empty-string $parameter |
| 36 | */ |
| 37 | public static function forParameter( |
| 38 | string $class, |
| 39 | string $parameter, |
| 40 | string $reason, |
| 41 | ): self { |
| 42 | return new self("Invalid hydration target '{$class}': parameter '\${$parameter}' {$reason}."); |
| 43 | } |
| 44 | |
| 45 | /** @param list<string> $rowKeys */ |
| 46 | public static function forClosureResult( |
| 47 | mixed $result, |
| 48 | ?string $sourcePath, |
| 49 | array $rowKeys, |
| 50 | ): self { |
| 51 | return new self( |
| 52 | 'Invalid hydration target returned by resolver from ' |
| 53 | . self::source($sourcePath) |
| 54 | . ': expected class-string, got ' |
| 55 | . self::valueType($result) |
| 56 | . '. Row keys: ' |
| 57 | . self::formatRowKeys($rowKeys) |
| 58 | . '.', |
| 59 | ); |
| 60 | } |
| 61 | } |
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.
| 47 | mixed $result, |
| 48 | ?string $sourcePath, |
| 49 | array $rowKeys, |
| 50 | ): self { |
| 51 | return new self( |
| 52 | 'Invalid hydration target returned by resolver from ' |
| 53 | . self::source($sourcePath) |
| 54 | . ': expected class-string, got ' |
| 55 | . self::valueType($result) |
| 56 | . '. Row keys: ' |
| 57 | . self::formatRowKeys($rowKeys) |
| 58 | . '.', |
| 59 | ); |
| 60 | } |
| 38 | string $class, |
| 39 | string $parameter, |
| 40 | string $reason, |
| 41 | ): self { |
| 42 | return new self("Invalid hydration target '{$class}': parameter '\${$parameter}' {$reason}."); |
| 43 | } |
| 14 | string $target, |
| 15 | ?string $sourcePath = null, |
| 16 | array $rowKeys = [], |
| 17 | string $reason = '', |
| 18 | ?Throwable $previous = null, |
| 19 | ): self { |
| 20 | $message = "Invalid hydration target '{$target}' from " . self::source($sourcePath); |
| 21 | |
| 22 | if ($reason !== '') { |
| 23 | $message .= ": {$reason}"; |
| 24 | } |
| 25 | |
| 26 | if ($rowKeys !== []) { |
| 26 | if ($rowKeys !== []) { |
| 27 | $message .= '. Row keys: ' . self::formatRowKeys($rowKeys); |
| 28 | } |
| 29 | |
| 30 | return new self($message . '.', 0, $previous); |
| 30 | return new self($message . '.', 0, $previous); |
| 31 | } |
| 14 | string $target, |
| 15 | ?string $sourcePath = null, |
| 16 | array $rowKeys = [], |
| 17 | string $reason = '', |
| 18 | ?Throwable $previous = null, |
| 19 | ): self { |
| 20 | $message = "Invalid hydration target '{$target}' from " . self::source($sourcePath); |
| 21 | |
| 22 | if ($reason !== '') { |
| 23 | $message .= ": {$reason}"; |
| 24 | } |
| 25 | |
| 26 | if ($rowKeys !== []) { |
| 26 | if ($rowKeys !== []) { |
| 30 | return new self($message . '.', 0, $previous); |
| 31 | } |
| 14 | string $target, |
| 15 | ?string $sourcePath = null, |
| 16 | array $rowKeys = [], |
| 17 | string $reason = '', |
| 18 | ?Throwable $previous = null, |
| 19 | ): self { |
| 20 | $message = "Invalid hydration target '{$target}' from " . self::source($sourcePath); |
| 21 | |
| 22 | if ($reason !== '') { |
| 26 | if ($rowKeys !== []) { |
| 27 | $message .= '. Row keys: ' . self::formatRowKeys($rowKeys); |
| 28 | } |
| 29 | |
| 30 | return new self($message . '.', 0, $previous); |
| 30 | return new self($message . '.', 0, $previous); |
| 31 | } |
| 14 | string $target, |
| 15 | ?string $sourcePath = null, |
| 16 | array $rowKeys = [], |
| 17 | string $reason = '', |
| 18 | ?Throwable $previous = null, |
| 19 | ): self { |
| 20 | $message = "Invalid hydration target '{$target}' from " . self::source($sourcePath); |
| 21 | |
| 22 | if ($reason !== '') { |
| 26 | if ($rowKeys !== []) { |
| 30 | return new self($message . '.', 0, $previous); |
| 31 | } |