| 1 | <?php |
||
| 17 | /** |
||
| 18 | * @Annotation |
||
| 19 | */ |
||
| 20 | abstract class BaseAnnotation |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Value property. Common among all derived classes. |
||
| 24 | */ |
||
| 25 | public string $value; |
||
|
|
|||
| 26 | |||
| 27 | /** |
||
| 28 | * Constructor |
||
| 29 | * |
||
| 30 | * @param array $data Key-value for properties to be defined in this class |
||
| 31 | 1 | */ |
|
| 32 | final public function __construct(array $data) |
||
| 33 | 1 | { |
|
| 34 | 1 | foreach ($data as $key => $value) { |
|
| 35 | $this->$key = $value; |
||
| 36 | 1 | } |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Error handler for unknown property accessor in Annotation class. |
||
| 41 | */ |
||
| 42 | public function __get(string $name) |
||
| 43 | { |
||
| 44 | throw new BadMethodCallException( |
||
| 45 | sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class) |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Error handler for unknown property mutator in Annotation class. |
||
| 51 | * |
||
| 52 | * @param mixed $value Property value |
||
| 53 | */ |
||
| 54 | public function __set(string $name, $value) |
||
| 55 | { |
||
| 56 | throw new BadMethodCallException( |
||
| 57 | sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class) |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |