| Total Complexity | 4 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class ValueObject |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Checks whether specified property exists. |
||
| 23 | * |
||
| 24 | * @param string $name Name of the property |
||
| 25 | * |
||
| 26 | * @return bool TRUE if the property exists, FALSE otherwise |
||
| 27 | */ |
||
| 28 | 1 | public function __isset(string $name): bool |
|
| 29 | { |
||
| 30 | 1 | return property_exists($this, $name); |
|
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Returns current value of specified property. |
||
| 35 | * |
||
| 36 | * @param string $name Name of the property |
||
| 37 | * |
||
| 38 | * @return mixed Current value of the property |
||
| 39 | * |
||
| 40 | * @throws \BadMethodCallException If the property doesn't exist |
||
| 41 | */ |
||
| 42 | 2 | public function __get(string $name) |
|
| 43 | { |
||
| 44 | 2 | if (!property_exists($this, $name)) { |
|
| 45 | 1 | throw new \BadMethodCallException(sprintf('Unknown property "%s" in class "%s".', $name, static::class)); |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | return $this->{$name}; |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Prevents object's properties from modification. |
||
| 53 | * |
||
| 54 | * @param string $name Name of the property |
||
| 55 | * @param mixed $value New value of the property |
||
| 56 | */ |
||
| 57 | 1 | final public function __set(string $name, $value) |
|
| 59 | 1 | } |
|
| 60 | } |
||
| 61 |