| Total Complexity | 4 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class Magic |
||
| 8 | { |
||
| 9 | private array $attributes; |
||
| 10 | |||
| 11 | public function __construct(array $attributes) |
||
| 12 | { |
||
| 13 | $this->attributes = $attributes; |
||
| 14 | } |
||
| 15 | |||
| 16 | public function __get(string $attribute) |
||
| 17 | { |
||
| 18 | if (!array_key_exists($attribute, $this->attributes)) { |
||
| 19 | throw new \InvalidArgumentException("There is no \"$attribute\""); |
||
| 20 | } |
||
| 21 | |||
| 22 | return $this->attributes[$attribute]; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function __set(string $attribute, $value) |
||
| 26 | { |
||
| 27 | $this->attributes[$attribute] = $value; |
||
| 28 | } |
||
| 30 |