1 | <?php |
||
22 | abstract class Base |
||
23 | { |
||
24 | /** |
||
25 | * Configuration values. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $config = array(); |
||
30 | |||
31 | /** |
||
32 | * Name of the element. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $name; |
||
37 | |||
38 | /** |
||
39 | * Label of the element. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $label; |
||
44 | |||
45 | /** |
||
46 | * Construct. |
||
47 | * |
||
48 | * @param string $name Name of the element. |
||
49 | * @param string $label Label of the element. |
||
50 | * @param array $config Configuration values. |
||
51 | */ |
||
52 | public function __construct(string $name, string $label = '', array $config = array()) |
||
58 | |||
59 | /** |
||
60 | * Get element label. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getLabel(): string |
||
68 | |||
69 | /** |
||
70 | * Set the label. |
||
71 | * |
||
72 | * @param string $label The label. |
||
73 | * |
||
74 | * @return $this |
||
75 | */ |
||
76 | public function setLabel(string $label): self |
||
82 | |||
83 | /** |
||
84 | * Get element name. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getName(): string |
||
92 | |||
93 | /** |
||
94 | * Set a config value. |
||
95 | * |
||
96 | * @param string $name Config property name. |
||
97 | * @param mixed $value Config property value. |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setConfigValue(string $name, $value): self |
||
107 | |||
108 | /** |
||
109 | * Get a config value. |
||
110 | * |
||
111 | * @param string $name Config property name. |
||
112 | * @param mixed $default Default value which is returned if config is not set. |
||
113 | * |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function getConfigValue(string $name, $default = null) |
||
124 | |||
125 | /** |
||
126 | * Consider if config value isset. |
||
127 | * |
||
128 | * @param string $name Name of the config value. |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function hasConfigValue(string $name): bool |
||
136 | |||
137 | /** |
||
138 | * Add multiple config properties. |
||
139 | * |
||
140 | * @param array $values Config values. |
||
141 | * |
||
142 | * @return $this |
||
143 | */ |
||
144 | public function addConfig(array $values): self |
||
152 | |||
153 | /** |
||
154 | * Remove a config property. |
||
155 | * |
||
156 | * @param string $name Config property name. |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function removeConfigValue(string $name): self |
||
166 | |||
167 | /** |
||
168 | * Get configuration. |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | public function getConfig(): array |
||
176 | } |
||
177 |