AuthValidationException.php
26 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Core\Exceptions; |
| 6 | |
| 7 | use InvalidArgumentException; |
| 8 | |
| 9 | /** |
| 10 | * Authentication Validation Exception. |
| 11 | */ |
| 12 | class AuthValidationException extends InvalidArgumentException |
| 13 | { |
| 14 | private const ERROR_MESSAGE_PREFIX = "Following authentication credentials are required:\n-> "; |
| 15 | |
| 16 | /** |
| 17 | * Initialize a new instance of AuthValidationException |
| 18 | * |
| 19 | * @param string[] $errors An array of errors in authentication validation |
| 20 | */ |
| 21 | public static function init(array $errors): AuthValidationException |
| 22 | { |
| 23 | return new self(self::ERROR_MESSAGE_PREFIX . join("\n-> ", $errors)); |
| 24 | } |
| 25 | } |
| 26 |