@@ -31,6 +31,11 @@ class ErrorSource implements Serializable
31
31
*/
32
32
private ?string $ parameter ;
33
33
34
+ /**
35
+ * @var string|null
36
+ */
37
+ private ?string $ header ;
38
+
34
39
/**
35
40
* @param ErrorSource|array|null $value
36
41
* @return ErrorSource
@@ -60,7 +65,8 @@ public static function fromArray(array $source): self
60
65
{
61
66
return new self (
62
67
$ source ['pointer ' ] ?? null ,
63
- $ source ['parameter ' ] ?? null
68
+ $ source ['parameter ' ] ?? null ,
69
+ $ source ['header ' ] ?? null ,
64
70
);
65
71
}
66
72
@@ -69,11 +75,13 @@ public static function fromArray(array $source): self
69
75
*
70
76
* @param string|null $pointer
71
77
* @param string|null $parameter
78
+ * @param string|null $header
72
79
*/
73
- public function __construct (?string $ pointer = null , ?string $ parameter = null )
80
+ public function __construct (?string $ pointer = null , ?string $ parameter = null , ? string $ header = null )
74
81
{
75
82
$ this ->pointer = $ pointer ;
76
83
$ this ->parameter = $ parameter ;
84
+ $ this ->header = $ header ;
77
85
}
78
86
79
87
/**
@@ -149,12 +157,47 @@ public function withoutParameter(): self
149
157
return $ this ;
150
158
}
151
159
160
+ /**
161
+ * A string indicating which request header caused the error.
162
+ *
163
+ * @return string|null
164
+ */
165
+ public function header (): ?string
166
+ {
167
+ return $ this ->header ;
168
+ }
169
+
170
+ /**
171
+ * Add a string indicating which request header caused the error.
172
+ *
173
+ * @param string|null $header
174
+ * @return $this
175
+ */
176
+ public function setHeader (?string $ header ): self
177
+ {
178
+ $ this ->header = $ header ;
179
+
180
+ return $ this ;
181
+ }
182
+
183
+ /**
184
+ * Remove the source header.
185
+ *
186
+ * @return $this
187
+ */
188
+ public function withoutHeader (): self
189
+ {
190
+ $ this ->header = null ;
191
+
192
+ return $ this ;
193
+ }
194
+
152
195
/**
153
196
* @return bool
154
197
*/
155
198
public function isEmpty (): bool
156
199
{
157
- return empty ($ this ->pointer ) && empty ($ this ->parameter );
200
+ return empty ($ this ->pointer ) && empty ($ this ->parameter ) && empty ( $ this -> header ) ;
158
201
}
159
202
160
203
/**
@@ -173,6 +216,7 @@ public function toArray()
173
216
return array_filter ([
174
217
'parameter ' => $ this ->parameter ,
175
218
'pointer ' => $ this ->pointer ,
219
+ 'header ' => $ this ->header ,
176
220
]);
177
221
}
178
222
0 commit comments