Skip to content

Commit 31ea9a4

Browse files
authored
feat: add header to error source objects (#24)
1 parent 240d720 commit 31ea9a4

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

src/Core/Document/ErrorSource.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class ErrorSource implements Serializable
3131
*/
3232
private ?string $parameter;
3333

34+
/**
35+
* @var string|null
36+
*/
37+
private ?string $header;
38+
3439
/**
3540
* @param ErrorSource|array|null $value
3641
* @return ErrorSource
@@ -60,7 +65,8 @@ public static function fromArray(array $source): self
6065
{
6166
return new self(
6267
$source['pointer'] ?? null,
63-
$source['parameter'] ?? null
68+
$source['parameter'] ?? null,
69+
$source['header'] ?? null,
6470
);
6571
}
6672

@@ -69,11 +75,13 @@ public static function fromArray(array $source): self
6975
*
7076
* @param string|null $pointer
7177
* @param string|null $parameter
78+
* @param string|null $header
7279
*/
73-
public function __construct(?string $pointer = null, ?string $parameter = null)
80+
public function __construct(?string $pointer = null, ?string $parameter = null, ?string $header = null)
7481
{
7582
$this->pointer = $pointer;
7683
$this->parameter = $parameter;
84+
$this->header = $header;
7785
}
7886

7987
/**
@@ -149,12 +157,47 @@ public function withoutParameter(): self
149157
return $this;
150158
}
151159

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+
152195
/**
153196
* @return bool
154197
*/
155198
public function isEmpty(): bool
156199
{
157-
return empty($this->pointer) && empty($this->parameter);
200+
return empty($this->pointer) && empty($this->parameter) && empty($this->header);
158201
}
159202

160203
/**
@@ -173,6 +216,7 @@ public function toArray()
173216
return array_filter([
174217
'parameter' => $this->parameter,
175218
'pointer' => $this->pointer,
219+
'header' => $this->header,
176220
]);
177221
}
178222

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy