Skip to content

Commit bcd5425

Browse files
committed
Add explicit getter and setter to FilterResponse
1 parent 8aa91de commit bcd5425

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

src/FilterResponse.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace TraderInteractive;
44

5+
use TraderInteractive\Exceptions\ReadOnlyViolationException;
6+
57
/**
68
* This object contains the various data returned by a filter action.
79
*
@@ -13,6 +15,11 @@
1315
*/
1416
final class FilterResponse
1517
{
18+
/**
19+
* @var array
20+
*/
21+
private $response;
22+
1623
/**
1724
* @param array $filteredValue The input values after being filtered.
1825
* @param array $errors Any errors encountered during the filter process.
@@ -23,11 +30,24 @@ public function __construct(
2330
array $errors = [],
2431
array $unknowns = []
2532
) {
26-
$this->success = count($errors) === 0;
27-
$this->filteredValue = $filteredValue;
28-
$this->errors = $errors;
29-
$this->errorMessage = $this->success ? null : implode("\n", $errors);
30-
$this->unknowns = $unknowns;
33+
$success = count($errors) === 0;
34+
$this->response = [
35+
'success' => $success,
36+
'filteredValue' => $filteredValue,
37+
'errors' => $errors,
38+
'errorMessage' => $success ? null : implode("\n", $errors),
39+
'unknowns' => $unknowns,
40+
];
41+
}
42+
43+
public function __get($name)
44+
{
45+
return $this->response[$name];
46+
}
47+
48+
public function __set($name, $value)
49+
{
50+
throw new ReadOnlyViolationException("Property {$name} is read-only");
3151
}
3252

3353
/**

0 commit comments

Comments
 (0)