-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApiResponseError.php
77 lines (63 loc) · 1.67 KB
/
ApiResponseError.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace Vayes\GoogleJsonStyleGuide;
class ApiResponseError
{
/**
* @var int|null
*
* Represents the code for this error.
* This property value will usually represent the HTTP response code.
* If there are multiple errors, code will be the error code for the first error.
*
* @example {"error": {"code": 401}
*/
private $code;
/**
* @var string|null
*
* A human readable message providing more details about the error.
* If there are multiple errors, message will be the message for the first error.
*
* @example {"error": {"message": "You don't have sufficient right to access here"}
*/
private $message;
/**
* @var null|array
*
* Container for any additional information regarding the error.
* If the service returns multiple errors, each element in the errors array represents a different error.
*
* @example {"error": {"errors": [...]}}
*/
private $errors;
public function getCode(): ?int
{
return $this->code;
}
public function setCode(?int $code): self
{
$this->code = $code;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): self
{
$this->message = $message;
return $this;
}
public function getErrors(): ?array
{
return $this->errors;
}
public function addError(ApiResponseErrorErrors $error): self
{
if (empty($this->errors)) {
$this->errors = [];
}
$this->errors[] = $error;
return $this;
}
}