Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| FileStorageException | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
6 | |||
| getStatusCode | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getChainedExceptions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Exceptions; |
| 3 | |
| 4 | use Apie\TypeConverter\Exceptions\GetMultipleChainedExceptionInterface; |
| 5 | use Throwable; |
| 6 | |
| 7 | final class FileStorageException extends ApieException implements HttpStatusCodeException, GetMultipleChainedExceptionInterface |
| 8 | { |
| 9 | /** |
| 10 | * @param array<int, Throwable> $exceptions |
| 11 | */ |
| 12 | public function __construct(string $message, private array $exceptions) |
| 13 | { |
| 14 | parent::__construct( |
| 15 | sprintf( |
| 16 | "%s:\n%s", |
| 17 | $message, |
| 18 | implode( |
| 19 | ",\n", |
| 20 | array_map( |
| 21 | function (Throwable $exception) { |
| 22 | return $exception->getMessage(); |
| 23 | }, |
| 24 | $exceptions |
| 25 | ) |
| 26 | ) |
| 27 | ), |
| 28 | 0, |
| 29 | empty($exceptions) ? null : reset($exceptions) |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | public function getStatusCode(): int |
| 34 | { |
| 35 | return 503; |
| 36 | } |
| 37 | |
| 38 | public function getChainedExceptions(): array |
| 39 | { |
| 40 | return $this->exceptions; |
| 41 | } |
| 42 | } |