1 | <?php |
||
17 | abstract class Entity { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $type; |
||
22 | |||
23 | /** |
||
24 | * @var array<string,mixed> |
||
25 | */ |
||
26 | private $properties = []; |
||
27 | |||
28 | /** |
||
29 | * @param string $type |
||
30 | * @param array<string,mixed> $properties |
||
31 | */ |
||
32 | 83 | public function __construct($type, array $properties) { |
|
39 | |||
40 | /** |
||
41 | * Get the type. |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | 66 | public function type() { |
|
48 | |||
49 | /** |
||
50 | * Set a new property. |
||
51 | * |
||
52 | * @param string $key |
||
53 | * @param mixed $value |
||
54 | * @throws \InvalidArgumentException if property is already set |
||
55 | * @return null |
||
56 | */ |
||
57 | 68 | private function set_property($key, $value) { |
|
64 | |||
65 | /** |
||
66 | * Get the properties. |
||
67 | * |
||
68 | * @return array<string,mixed> |
||
69 | */ |
||
70 | 7 | public function properties() { |
|
73 | |||
74 | /** |
||
75 | * Get one property. |
||
76 | * |
||
77 | * @param string $name |
||
78 | * @throws \InvalidArgumentException if named propery does not exist |
||
79 | * @return mixed |
||
80 | */ |
||
81 | 41 | public function property($name) { |
|
89 | |||
90 | /** |
||
91 | * Check if entity has a property. |
||
92 | * |
||
93 | * @param string $name |
||
94 | * @return bool |
||
95 | */ |
||
96 | 42 | public function has_property($name) { |
|
99 | } |
||
100 |