1 | <?php |
||
13 | class Manager |
||
14 | { |
||
15 | /** |
||
16 | * @var Property[] |
||
17 | */ |
||
18 | private $properties = []; |
||
19 | |||
20 | /** |
||
21 | * Add a new property to the stack |
||
22 | * |
||
23 | * @param string $name the property name |
||
24 | 18 | * @param string $type the data type for the property (string, int, bool, etc) |
|
25 | * @param mixed $default the default value, until explicity assigned this is |
||
26 | 18 | * the value for the property |
|
27 | 18 | */ |
|
28 | public function addProperty($name, $type = null, $default = null): Property |
||
35 | |||
36 | /** |
||
37 | * Get the property by its name |
||
38 | * |
||
39 | 12 | * @param string $name |
|
40 | * @return Property |
||
41 | 12 | * @throws Exception if the property doesn't exist |
|
42 | 3 | */ |
|
43 | public function getProperty(string $name): Property |
||
50 | |||
51 | /** |
||
52 | * Does the manager contain an instance of the property |
||
53 | 18 | * based on it's name |
|
54 | * @param string $name property identifier |
||
55 | 18 | * @return boolean |
|
56 | */ |
||
57 | public function hasProperty(string $name): bool |
||
61 | |||
62 | /** |
||
63 | 3 | * Get all of the properties registered by the manager |
|
64 | * |
||
65 | 3 | * @return Property[] |
|
66 | 3 | */ |
|
67 | public function allProperties(): array |
||
71 | |||
72 | /** |
||
73 | * Remove the property from the manager |
||
74 | * |
||
75 | * @param string $name |
||
76 | * @return bool |
||
77 | */ |
||
78 | 9 | public function removeProperty(string $name): bool |
|
86 | |||
87 | /** |
||
88 | * Get the value of the property, if it exists |
||
89 | 6 | * |
|
90 | * @param string $name property name |
||
91 | 6 | * @return mixed |
|
92 | * @throws Exception if the property doesn't exist |
||
93 | */ |
||
94 | public function getValue(string $name) |
||
98 | |||
99 | /** |
||
100 | * Set the value of the property, if it exists |
||
101 | * |
||
102 | * @param string $name the property identifier |
||
103 | * @param mixed $value the value to store against the property |
||
104 | * @throws Exception if the property doesn't exist |
||
105 | */ |
||
106 | public function setValue(string $name, $value) |
||
110 | } |
||
111 |