| 1 | <?php |
||
| 5 | class ValidationException extends \RuntimeException |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var int |
||
| 9 | */ |
||
| 10 | private $statusCode; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | private $statusMessage; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var Error[] |
||
| 19 | */ |
||
| 20 | private $errors; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * ValidationException constructor. |
||
| 24 | * |
||
| 25 | * Exception thrown when the moip API returns a 4xx http code. |
||
| 26 | * Indicates that an invalid value was passed. |
||
| 27 | * |
||
| 28 | * @param int $statusCode |
||
| 29 | * @param string $statusMessage |
||
| 30 | * @param Error[] $errors |
||
| 31 | */ |
||
| 32 | public function __construct($statusCode, $statusMessage, $errors) |
||
| 33 | { |
||
| 34 | $this->errors = $errors; |
||
| 35 | $this->statusCode = $statusCode; |
||
| 36 | $this->statusMessage = $statusMessage; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Returns the http status code ie.: 400. |
||
| 41 | * |
||
| 42 | * @return int |
||
| 43 | */ |
||
| 44 | public function getStatusCode() |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Returns the http status code description: ie.: 'Bad Request'. |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getStatusMessage() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Returns the list of errors returned by the API. |
||
| 61 | * |
||
| 62 | * @return Error[] |
||
| 63 | * |
||
| 64 | * @see \Moip\Exceptions\Error |
||
| 65 | */ |
||
| 66 | public function getErrors() |
||
| 70 | |||
| 71 | public function __toString() |
||
| 84 | } |
||
| 85 |