Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| CanNotLoginException | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 10 |
|
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\Common\Exceptions; |
| 3 | |
| 4 | use Apie\Core\Exceptions\HttpStatusCodeException; |
| 5 | use Apie\TypeConverter\Exceptions\GetMultipleChainedExceptionInterface; |
| 6 | use LogicException; |
| 7 | use Throwable; |
| 8 | |
| 9 | final class CanNotLoginException extends LogicException implements GetMultipleChainedExceptionInterface, HttpStatusCodeException |
| 10 | { |
| 11 | /** |
| 12 | * @param array<string, Throwable> $errors |
| 13 | */ |
| 14 | public function __construct(private array $errors) |
| 15 | { |
| 16 | $messages = []; |
| 17 | $previous = null; |
| 18 | foreach ($errors as $error) { |
| 19 | $messages[] = '"' . $error->getMessage() . '"'; |
| 20 | $previous = $error; |
| 21 | } |
| 22 | parent::__construct( |
| 23 | 'Can not login: ' . implode(', ', $messages), |
| 24 | 0, |
| 25 | $previous |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | public function getStatusCode(): int |
| 30 | { |
| 31 | return 401; |
| 32 | } |
| 33 | |
| 34 | public function getChainedExceptions(): array |
| 35 | { |
| 36 | return $this->errors; |
| 37 | } |
| 38 | } |