1 | <?php |
||
10 | class Error |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $code; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $path; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $description; |
||
26 | |||
27 | /** |
||
28 | * Error constructor. |
||
29 | * |
||
30 | * Represents an error return by the API. Commonly used by {@see \Moip\Exceptions\ValidationException} |
||
31 | * |
||
32 | * @param string $code unique error identifier. |
||
33 | * @param string $path represents the field where the error ocurred. |
||
34 | * @param string $description error description. |
||
35 | */ |
||
36 | public function __construct($code, $path, $description) |
||
42 | |||
43 | /** |
||
44 | * Returns the unique alphanumeric identifier of the error, ie.: "API-1". |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getCode() |
||
52 | |||
53 | /** |
||
54 | * Returns the dotted string representing the field where the error ocurred, ie.: "customer.birthDate". |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getPath() |
||
62 | |||
63 | /** |
||
64 | * Returns the error description. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getDescription() |
||
72 | |||
73 | /** |
||
74 | * Creates an Error array from a json string. |
||
75 | * |
||
76 | * @param string $json_string string returned by the Moip API |
||
77 | * |
||
78 | * @return Error[] |
||
79 | */ |
||
80 | public static function parseErrors($json_string) |
||
92 | } |
||
93 |