| Total Complexity | 2 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | final class InputDataCannotBeEncoded extends InvalidArgument implements InvalidJson |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Produces an `Invalid Json` type exception, to throw when encoding the |
||
| 19 | * input caused an exception. |
||
| 20 | * |
||
| 21 | * @param Throwable $exception The exception that was thrown while encoding. |
||
| 22 | * @return InvalidJson The Json context-specific exception to throw. |
||
| 23 | */ |
||
| 24 | public static function encountered(Throwable $exception): InvalidJson |
||
| 25 | { |
||
| 26 | return new self(sprintf( |
||
| 27 | 'Encoding the input caused an exception: %s', |
||
| 28 | $exception->getMessage() |
||
| 29 | )); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Produces an `Invalid Json` type exception, to throw when encoding the |
||
| 34 | * input caused an error. |
||
| 35 | * |
||
| 36 | * @param string $error The Json error that was found. |
||
| 37 | * @return InvalidJson The Json context-specific exception to throw. |
||
| 38 | */ |
||
| 39 | public static function found(string $error): InvalidJson |
||
| 44 | )); |
||
| 45 | } |
||
| 47 |