|
2 | 2 |
|
3 | 3 | namespace TraderInteractive; |
4 | 4 |
|
| 5 | +use InvalidArgumentException; |
5 | 6 | use TraderInteractive\Exceptions\ReadOnlyViolationException; |
6 | 7 |
|
7 | 8 | /** |
8 | 9 | * This object contains the various data returned by a filter action. |
9 | 10 | * |
10 | | - * @property-read bool $success TRUE if the filter was successful or FALSE if errors were encountered. |
11 | | - * @property-read mixed $filteredValue The input values after being filtered. |
12 | | - * @property-read array $errors Any errors encountered during the filter process. |
13 | | - * @property-read string|null $errorMessage An error message generated from the errors. NULL if no errors. |
14 | | - * @property-read mixed $unknowns The values that were unknown during filtering. |
| 11 | + * @property bool $success TRUE if the filter was successful or FALSE if errors were encountered. |
| 12 | + * @property mixed $filteredValue The input values after being filtered. |
| 13 | + * @property array $errors Any errors encountered during the filter process. |
| 14 | + * @property string|null $errorMessage An error message generated from the errors. NULL if no errors. |
| 15 | + * @property mixed $unknowns The values that were unknown during filtering. |
15 | 16 | */ |
16 | 17 | final class FilterResponse |
17 | 18 | { |
@@ -42,12 +43,20 @@ public function __construct( |
42 | 43 |
|
43 | 44 | public function __get($name) |
44 | 45 | { |
45 | | - return $this->response[$name]; |
| 46 | + if (array_key_exists($name, $this->response)) { |
| 47 | + return $this->response[$name]; |
| 48 | + } |
| 49 | + |
| 50 | + throw new InvalidArgumentException("Property '{$name}' does not exist"); |
46 | 51 | } |
47 | 52 |
|
48 | 53 | public function __set($name, $value) |
49 | 54 | { |
50 | | - throw new ReadOnlyViolationException("Property {$name} is read-only"); |
| 55 | + if (array_key_exists($name, $this->response)) { |
| 56 | + throw new ReadOnlyViolationException("Property '{$name}' is read-only"); |
| 57 | + } |
| 58 | + |
| 59 | + throw new InvalidArgumentException("Property '{$name}' does not exist"); |
51 | 60 | } |
52 | 61 |
|
53 | 62 | /** |
|
0 commit comments