1 | <?php |
||
18 | class ErrorObject implements LinksAwareInterface, MetadataAwareInterface |
||
19 | { |
||
20 | use LinksContainer; |
||
21 | use MetadataContainer; |
||
22 | |||
23 | /** |
||
24 | * Identifier of occurrence |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * HTTP status code |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $status; |
||
36 | |||
37 | /** |
||
38 | * Application specific code |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $code; |
||
43 | |||
44 | /** |
||
45 | * Human-readable summary |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $title; |
||
50 | |||
51 | /** |
||
52 | * Human-readable explanation |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $detail; |
||
57 | |||
58 | /** |
||
59 | * ErrorObject constructor. |
||
60 | * |
||
61 | * @param string $id |
||
62 | * @param string $title |
||
63 | */ |
||
64 | 10 | public function __construct(string $id = null, string $title = null) |
|
65 | { |
||
66 | 10 | $this->id = $id; |
|
67 | 10 | $this->title = $title; |
|
68 | 10 | } |
|
69 | |||
70 | /** |
||
71 | * Set ID of occurrence |
||
72 | * |
||
73 | * @param string $id |
||
74 | */ |
||
75 | 2 | public function setId(string $id) |
|
76 | { |
||
77 | 2 | $this->id = $id; |
|
78 | 2 | } |
|
79 | |||
80 | /** |
||
81 | * Has ID of occurrence ? |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function hasId(): bool |
||
89 | |||
90 | /** |
||
91 | * Get ID of occurrence |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 1 | public function getId(): string |
|
96 | { |
||
97 | 1 | return $this->id; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Set HTTP status code |
||
102 | * |
||
103 | * @param string $status |
||
104 | */ |
||
105 | 2 | public function setStatus(string $status) |
|
106 | { |
||
107 | 2 | $this->status = $status; |
|
108 | 2 | } |
|
109 | |||
110 | /** |
||
111 | * Has HTTP status code ? |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function hasStatus(): bool |
||
119 | |||
120 | /** |
||
121 | * Get HTTP status code |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 1 | public function getStatus(): string |
|
126 | { |
||
127 | 1 | return $this->status; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * Set application specific code |
||
132 | * |
||
133 | * @param string $code |
||
134 | */ |
||
135 | 2 | public function setCode(string $code) |
|
136 | { |
||
137 | 2 | $this->code = $code; |
|
138 | 2 | } |
|
139 | |||
140 | /** |
||
141 | * Has application specific code |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function hasCode(): bool |
||
149 | |||
150 | /** |
||
151 | * Get application specific code |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | public function getCode(): string |
|
156 | { |
||
157 | 1 | return $this->code; |
|
158 | } |
||
159 | |||
160 | /** |
||
161 | * Set title |
||
162 | * |
||
163 | * @param string $title |
||
164 | */ |
||
165 | 2 | public function setTitle(string $title) |
|
166 | { |
||
167 | 2 | $this->title = $title; |
|
168 | 2 | } |
|
169 | |||
170 | /** |
||
171 | * Has title |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function hasTitle(): bool |
||
179 | |||
180 | /** |
||
181 | * Get title |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | 1 | public function getTitle(): string |
|
186 | { |
||
187 | 1 | return $this->title; |
|
188 | } |
||
189 | |||
190 | /** |
||
191 | * Set detailed explanation |
||
192 | * |
||
193 | * @param string $detail |
||
194 | */ |
||
195 | 2 | public function setDetail(string $detail) |
|
196 | { |
||
197 | 2 | $this->detail = $detail; |
|
198 | 2 | } |
|
199 | |||
200 | /** |
||
201 | * Has detailed explanation ? |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | public function hasDetail(): bool |
||
209 | |||
210 | /** |
||
211 | * Get detailed explanation |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | 1 | public function getDetail(): string |
|
216 | { |
||
217 | 1 | return $this->detail; |
|
218 | } |
||
219 | |||
220 | /** |
||
221 | * Cast to an array |
||
222 | * |
||
223 | * @return array |
||
224 | */ |
||
225 | 3 | public function toArray(): array |
|
245 | } |