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