1 | <?php |
||
19 | class ColorModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * Default colors. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | private $default_colors = [ |
||
27 | 'white' => [ |
||
28 | 'name' => 'White', |
||
29 | 'border-left-color' => '#CCCCCC', |
||
30 | 'border-width' => '3px', |
||
31 | ], |
||
32 | 'yellow' => [ |
||
33 | 'name' => 'Yellow', |
||
34 | 'border-left-color' => '#F5F7C4', |
||
35 | 'border-width' => '3px', |
||
36 | ], |
||
37 | 'blue' => [ |
||
38 | 'name' => 'Blue', |
||
39 | 'border-left-color' => '#DBEBFF', |
||
40 | 'border-width' => '3px', |
||
41 | ], |
||
42 | 'green' => [ |
||
43 | 'name' => 'Green', |
||
44 | 'border-left-color' => '#BDF4CB', |
||
45 | 'border-width' => '3px', |
||
46 | ], |
||
47 | 'purple' => [ |
||
48 | 'name' => 'Purple', |
||
49 | 'border-left-color' => '#DFB0FF', |
||
50 | 'border-width' => '3px', |
||
51 | ], |
||
52 | 'red' => [ |
||
53 | 'name' => 'Red', |
||
54 | 'border-left-color' => '#FFBBBB', |
||
55 | 'border-width' => '3px', |
||
56 | ], |
||
57 | 'orange' => [ |
||
58 | 'name' => 'Orange', |
||
59 | 'border-left-color' => '#FFD7B3', |
||
60 | 'border-width' => '3px', |
||
61 | ], |
||
62 | 'grey' => [ |
||
63 | 'name' => 'Grey', |
||
64 | 'border-left-color' => '#EEEEEE', |
||
65 | 'border-width' => '3px', |
||
66 | ], |
||
67 | 'brown' => [ |
||
68 | 'name' => 'Brown', |
||
69 | 'border-left-color' => '#D7CCC8', |
||
70 | 'border-width' => '3px', |
||
71 | ], |
||
72 | 'deep_orange' => [ |
||
73 | 'name' => 'Deep Orange', |
||
74 | 'border-left-color' => '#FFAB91', |
||
75 | 'border-width' => '3px', |
||
76 | ], |
||
77 | 'dark_grey' => [ |
||
78 | 'name' => 'Dark Grey', |
||
79 | 'border-left-color' => '#CFD8DC', |
||
80 | 'border-width' => '3px', |
||
81 | ], |
||
82 | 'pink' => [ |
||
83 | 'name' => 'Pink', |
||
84 | 'border-left-color' => '#F48FB1', |
||
85 | 'border-width' => '3px', |
||
86 | ], |
||
87 | 'teal' => [ |
||
88 | 'name' => 'Teal', |
||
89 | 'border-left-color' => '#80CBC4', |
||
90 | 'border-width' => '3px', |
||
91 | ], |
||
92 | 'cyan' => [ |
||
93 | 'name' => 'Cyan', |
||
94 | 'border-left-color' => '#B2EBF2', |
||
95 | 'border-width' => '3px', |
||
96 | ], |
||
97 | 'lime' => [ |
||
98 | 'name' => 'Lime', |
||
99 | 'border-left-color' => '#E6EE9C', |
||
100 | 'border-width' => '3px', |
||
101 | ], |
||
102 | 'light_green' => [ |
||
103 | 'name' => 'Light Green', |
||
104 | 'border-left-color' => '#DCEDC8', |
||
105 | 'border-width' => '3px', |
||
106 | ], |
||
107 | 'amber' => [ |
||
108 | 'name' => 'Amber', |
||
109 | 'border-left-color' => '#FFE082', |
||
110 | 'border-width' => '3px', |
||
111 | ], |
||
112 | ]; |
||
113 | |||
114 | /** |
||
115 | * Find a color id from the name or the id. |
||
116 | * |
||
117 | * @param string $color |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function find($color) |
||
135 | |||
136 | /** |
||
137 | * Get color properties. |
||
138 | * |
||
139 | * @param string $color_id |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | public function getColorProperties($color_id) |
||
151 | |||
152 | /** |
||
153 | * Get available colors. |
||
154 | * |
||
155 | * @param bool $prepend |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | public function getList($prepend = false) |
||
171 | |||
172 | /** |
||
173 | * Get the default color. |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | public function getDefaultColor() |
||
181 | |||
182 | /** |
||
183 | * Get the default colors. |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | public function getDefaultColors() |
||
191 | |||
192 | /** |
||
193 | * Get border width from string. |
||
194 | * |
||
195 | * @param string $color_id Color id |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getBorderWidth($color_id) |
||
200 | { |
||
201 | $color = $this->getColorProperties($color_id); |
||
202 | |||
203 | return $color['border-width']; |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Get border left color from the color_id. |
||
208 | * |
||
209 | * @param string $color_id Color id |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | public function getBorderLeftColor($color_id) |
||
214 | { |
||
215 | $color = $this->getColorProperties($color_id); |
||
216 | |||
217 | return $color['border-left-color']; |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * Get CSS stylesheet of all colors. |
||
222 | * |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getCss() |
||
239 | } |
||
240 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.