@@ -8,22 +8,22 @@ discard block |
||
8 | 8 | * @property string $root |
9 | 9 | * @property string $attr |
10 | 10 | */ |
11 | -trait NavElementTrait{ |
|
11 | +trait NavElementTrait { |
|
12 | 12 | |
13 | 13 | abstract public function contentAsString(); |
14 | 14 | /** |
15 | 15 | * Generate the jquery script to set the elements to the HtmlNavElement |
16 | 16 | * @param JsUtils $jsUtils |
17 | 17 | */ |
18 | - public function jsSetContent(JsUtils $jsUtils){ |
|
19 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
18 | + public function jsSetContent(JsUtils $jsUtils) { |
|
19 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function getRoot() { |
23 | 23 | return $this->root; |
24 | 24 | } |
25 | 25 | public function setRoot($root) { |
26 | - $this->root = $root; |
|
26 | + $this->root=$root; |
|
27 | 27 | return $this; |
28 | 28 | } |
29 | 29 | public function getAttr() { |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | * @return HtmlNavElement |
37 | 37 | */ |
38 | 38 | public function setAttr($attr) { |
39 | - $this->attr = $attr; |
|
39 | + $this->attr=$attr; |
|
40 | 40 | return $this; |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function __call($method, $args) { |
44 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
44 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
45 | 45 | return call_user_func_array( |
46 | 46 | $this->$method, |
47 | 47 | $args |
@@ -49,5 +49,5 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0); |
|
52 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
53 | 53 | } |
@@ -19,215 +19,215 @@ discard block |
||
19 | 19 | |
20 | 20 | public static $index=0; |
21 | 21 | |
22 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
22 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
26 | + if (isset($instance)) |
|
27 | 27 | $this->setInstance($instance); |
28 | 28 | $this->setCaptions($captions); |
29 | 29 | $this->captionCallback=NULL; |
30 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
30 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
31 | 31 | } |
32 | 32 | |
33 | - public function moveFieldTo($from,$to){ |
|
34 | - if(JArray::moveElementTo($this->visibleProperties, $from, $to)){ |
|
33 | + public function moveFieldTo($from, $to) { |
|
34 | + if (JArray::moveElementTo($this->visibleProperties, $from, $to)) { |
|
35 | 35 | return JArray::moveElementTo($this->values, $from, $to); |
36 | 36 | } |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - public function swapFields($index1,$index2){ |
|
41 | - if(JArray::swapElements($this->visibleProperties, $index1, $index2)){ |
|
40 | + public function swapFields($index1, $index2) { |
|
41 | + if (JArray::swapElements($this->visibleProperties, $index1, $index2)) { |
|
42 | 42 | return JArray::swapElements($this->values, $index1, $index2); |
43 | 43 | } |
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | - public function removeField($index){ |
|
48 | - \array_splice($this->visibleProperties,$index,1); |
|
49 | - \array_splice($this->values,$index,1); |
|
50 | - \array_splice($this->captions,$index,1); |
|
47 | + public function removeField($index) { |
|
48 | + \array_splice($this->visibleProperties, $index, 1); |
|
49 | + \array_splice($this->values, $index, 1); |
|
50 | + \array_splice($this->captions, $index, 1); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function getValues(){ |
|
54 | + public function getValues() { |
|
55 | 55 | $values=[]; |
56 | 56 | $index=0; |
57 | 57 | $count=$this->count(); |
58 | - while($index<$count){ |
|
58 | + while ($index<$count) { |
|
59 | 59 | $values[]=$this->getValue($index++); |
60 | 60 | } |
61 | 61 | return $values; |
62 | 62 | } |
63 | 63 | |
64 | - public function getIdentifier($index=NULL){ |
|
65 | - if(!isset($index)) |
|
64 | + public function getIdentifier($index=NULL) { |
|
65 | + if (!isset($index)) |
|
66 | 66 | $index=self::$index; |
67 | 67 | $value=$index; |
68 | - if(isset($this->values["identifier"])){ |
|
69 | - if(\is_string($this->values["identifier"])) |
|
68 | + if (isset($this->values["identifier"])) { |
|
69 | + if (\is_string($this->values["identifier"])) |
|
70 | 70 | $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
71 | 71 | else |
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
72 | + $value=$this->values["identifier"]($index, $this->instance); |
|
73 | 73 | } |
74 | 74 | return $value; |
75 | 75 | } |
76 | 76 | |
77 | - public function getValue($index){ |
|
77 | + public function getValue($index) { |
|
78 | 78 | $property=$this->properties[$index]; |
79 | 79 | return $this->_getValue($property, $index); |
80 | 80 | } |
81 | 81 | |
82 | - protected function _beforeAddProperty($index,&$field){ |
|
82 | + protected function _beforeAddProperty($index, &$field) { |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - protected function _getDefaultValue($name,$value,$index){ |
|
86 | + protected function _getDefaultValue($name, $value, $index) { |
|
87 | 87 | $func=$this->defaultValueFunction; |
88 | - return $func($name,$value,$index,$this->instance); |
|
88 | + return $func($name, $value, $index, $this->instance); |
|
89 | 89 | } |
90 | 90 | |
91 | - protected function _getPropertyValue(\ReflectionProperty $property,$index){ |
|
91 | + protected function _getPropertyValue(\ReflectionProperty $property, $index) { |
|
92 | 92 | $property->setAccessible(true); |
93 | 93 | return $property->getValue($this->instance); |
94 | 94 | } |
95 | 95 | |
96 | - protected function _getValue($property,$index){ |
|
96 | + protected function _getValue($property, $index) { |
|
97 | 97 | $value=null; |
98 | 98 | $propertyName=$property; |
99 | - if($property instanceof \ReflectionProperty){ |
|
99 | + if ($property instanceof \ReflectionProperty) { |
|
100 | 100 | $value=$this->_getPropertyValue($property, $index); |
101 | 101 | $propertyName=$property->getName(); |
102 | - }elseif(\is_callable($property)) |
|
102 | + }elseif (\is_callable($property)) |
|
103 | 103 | $value=$property($this->instance); |
104 | - elseif(\is_array($property)){ |
|
105 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
104 | + elseif (\is_array($property)) { |
|
105 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
106 | 106 | $value=\implode("", $values); |
107 | - }elseif(\is_string($property)){ |
|
107 | + }elseif (\is_string($property)) { |
|
108 | 108 | $value=$property; |
109 | - if(isset($this->instance->{$property})){ |
|
109 | + if (isset($this->instance->{$property})) { |
|
110 | 110 | $value=$this->instance->{$property}; |
111 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
111 | + }elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) { |
|
112 | 112 | $value=JReflection::callMethod($this->instance, $getter, []); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | return $this->_postGetValue($index, $propertyName, $value); |
116 | 116 | } |
117 | 117 | |
118 | - protected function _postGetValue($index,$propertyName,$value){ |
|
119 | - if(isset($this->values[$index])){ |
|
120 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
121 | - }else{ |
|
122 | - $value=$this->_getDefaultValue($propertyName,$value, $index); |
|
118 | + protected function _postGetValue($index, $propertyName, $value) { |
|
119 | + if (isset($this->values[$index])) { |
|
120 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
121 | + } else { |
|
122 | + $value=$this->_getDefaultValue($propertyName, $value, $index); |
|
123 | 123 | } |
124 | - if(isset($this->afterCompile[$index])){ |
|
125 | - if(\is_callable($this->afterCompile[$index])){ |
|
126 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
124 | + if (isset($this->afterCompile[$index])) { |
|
125 | + if (\is_callable($this->afterCompile[$index])) { |
|
126 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | return $value; |
130 | 130 | } |
131 | 131 | |
132 | - public function insertField($index,$field){ |
|
133 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
132 | + public function insertField($index, $field) { |
|
133 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function insertInField($index,$field){ |
|
137 | + public function insertInField($index, $field) { |
|
138 | 138 | $vb=$this->visibleProperties; |
139 | - if(isset($vb[$index])){ |
|
140 | - if(\is_array($vb[$index])){ |
|
139 | + if (isset($vb[$index])) { |
|
140 | + if (\is_array($vb[$index])) { |
|
141 | 141 | $this->visibleProperties[$index][]=$field; |
142 | - }else{ |
|
143 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
142 | + } else { |
|
143 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
144 | 144 | } |
145 | - }else{ |
|
145 | + } else { |
|
146 | 146 | return $this->insertField($index, $field); |
147 | 147 | } |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function addField($field){ |
|
151 | + public function addField($field) { |
|
152 | 152 | $this->visibleProperties[]=$field; |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function count(){ |
|
156 | + public function count() { |
|
157 | 157 | return \sizeof($this->properties); |
158 | 158 | } |
159 | 159 | |
160 | - public function visiblePropertiesCount(){ |
|
160 | + public function visiblePropertiesCount() { |
|
161 | 161 | return \sizeof($this->visibleProperties); |
162 | 162 | } |
163 | 163 | |
164 | - public function getProperty($index){ |
|
164 | + public function getProperty($index) { |
|
165 | 165 | return $this->properties[$index]; |
166 | 166 | } |
167 | 167 | |
168 | - public function getFieldName($index){ |
|
168 | + public function getFieldName($index) { |
|
169 | 169 | $property=$this->getProperty($index); |
170 | - if($property instanceof \ReflectionProperty){ |
|
170 | + if ($property instanceof \ReflectionProperty) { |
|
171 | 171 | $result=$property->getName(); |
172 | - }elseif(\is_callable($property)){ |
|
172 | + }elseif (\is_callable($property)) { |
|
173 | 173 | $result=$this->visibleProperties[$index]; |
174 | - }else{ |
|
174 | + } else { |
|
175 | 175 | $result=$property; |
176 | 176 | } |
177 | 177 | return $result; |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
182 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
181 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
182 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | public function setInstance($instance) { |
186 | - if(\is_string($instance)){ |
|
186 | + if (\is_string($instance)) { |
|
187 | 187 | $instance=new $instance(); |
188 | 188 | } |
189 | 189 | $this->instance=$instance; |
190 | 190 | $this->properties=[]; |
191 | 191 | $this->reflect=new \ReflectionClass($instance); |
192 | - if(\sizeof($this->visibleProperties)===0){ |
|
192 | + if (\sizeof($this->visibleProperties)===0) { |
|
193 | 193 | $this->properties=$this->getDefaultProperties(); |
194 | - }else{ |
|
195 | - foreach ($this->visibleProperties as $property){ |
|
194 | + } else { |
|
195 | + foreach ($this->visibleProperties as $property) { |
|
196 | 196 | $this->setInstanceProperty($property); |
197 | 197 | } |
198 | 198 | } |
199 | 199 | return $this; |
200 | 200 | } |
201 | 201 | |
202 | - private function setInstanceProperty($property){ |
|
203 | - if(\is_callable($property)){ |
|
202 | + private function setInstanceProperty($property) { |
|
203 | + if (\is_callable($property)) { |
|
204 | 204 | $this->properties[]=$property; |
205 | - }elseif(\is_string($property)){ |
|
206 | - try{ |
|
205 | + }elseif (\is_string($property)) { |
|
206 | + try { |
|
207 | 207 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
208 | 208 | $rProperty=$this->reflect->getProperty($property); |
209 | 209 | $this->properties[]=$rProperty; |
210 | - }catch(\Exception $e){ |
|
210 | + }catch (\Exception $e) { |
|
211 | 211 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
212 | 212 | $this->properties[]=$property; |
213 | 213 | } |
214 | - }elseif(\is_int($property)){ |
|
214 | + }elseif (\is_int($property)) { |
|
215 | 215 | $props=$this->getDefaultProperties(); |
216 | - if(isset($props[$property])) |
|
216 | + if (isset($props[$property])) |
|
217 | 217 | $this->properties[]=$props[$property]; |
218 | 218 | else |
219 | 219 | $this->properties[]=$property; |
220 | - }else{ |
|
220 | + } else { |
|
221 | 221 | $this->properties[]=$property; |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | - protected function getDefaultProperties(){ |
|
225 | + protected function getDefaultProperties() { |
|
226 | 226 | $result=[]; |
227 | 227 | $properties=$this->reflect->getProperties(); |
228 | - foreach ($properties as $property){ |
|
228 | + foreach ($properties as $property) { |
|
229 | 229 | $showable=$this->showableProperty($property); |
230 | - if($showable!==false){ |
|
230 | + if ($showable!==false) { |
|
231 | 231 | $result[]=$property; |
232 | 232 | } |
233 | 233 | } |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | return $this; |
240 | 240 | } |
241 | 241 | |
242 | - public function setValueFunction($index,$callback){ |
|
242 | + public function setValueFunction($index, $callback) { |
|
243 | 243 | $this->values[$index]=$callback; |
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - public function setIdentifierFunction($callback){ |
|
247 | + public function setIdentifierFunction($callback) { |
|
248 | 248 | $this->values["identifier"]=$callback; |
249 | 249 | return $this; |
250 | 250 | } |
@@ -257,42 +257,42 @@ discard block |
||
257 | 257 | return $this->properties; |
258 | 258 | } |
259 | 259 | |
260 | - public function getCaption($index){ |
|
261 | - if(isset($this->captions[$index])){ |
|
260 | + public function getCaption($index) { |
|
261 | + if (isset($this->captions[$index])) { |
|
262 | 262 | return $this->captions[$index]; |
263 | 263 | } |
264 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
264 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
265 | 265 | return $this->properties[$index]->getName(); |
266 | - elseif(\is_callable($this->properties[$index])) |
|
266 | + elseif (\is_callable($this->properties[$index])) |
|
267 | 267 | return ""; |
268 | 268 | else |
269 | 269 | return $this->properties[$index]; |
270 | 270 | } |
271 | 271 | |
272 | - public function getCaptions(){ |
|
273 | - if(isset($this->captions)){ |
|
274 | - $captions= \array_values($this->captions); |
|
272 | + public function getCaptions() { |
|
273 | + if (isset($this->captions)) { |
|
274 | + $captions=\array_values($this->captions); |
|
275 | 275 | $captionsSize=\sizeof($captions); |
276 | - for($i=$captionsSize;$i<$this->count();$i++){ |
|
276 | + for ($i=$captionsSize; $i<$this->count(); $i++) { |
|
277 | 277 | $captions[]=""; |
278 | 278 | } |
279 | - }else{ |
|
279 | + } else { |
|
280 | 280 | $captions=[]; |
281 | 281 | $index=0; |
282 | 282 | $count=$this->count(); |
283 | - while($index<$count){ |
|
283 | + while ($index<$count) { |
|
284 | 284 | $captions[]=$this->getCaption($index++); |
285 | 285 | } |
286 | 286 | } |
287 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
287 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
288 | 288 | $callback=$this->captionCallback; |
289 | - $callback($captions,$this->instance); |
|
289 | + $callback($captions, $this->instance); |
|
290 | 290 | } |
291 | 291 | return $captions; |
292 | 292 | } |
293 | 293 | |
294 | - public function setCaption($index,$caption){ |
|
295 | - if(isset($this->captions)===false) |
|
294 | + public function setCaption($index, $caption) { |
|
295 | + if (isset($this->captions)===false) |
|
296 | 296 | $this->captions=[]; |
297 | 297 | $this->captions[$index]=$caption; |
298 | 298 | return $this; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param callable $callback function called after the field compilation |
311 | 311 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
312 | 312 | */ |
313 | - public function afterCompile($index,$callback){ |
|
313 | + public function afterCompile($index, $callback) { |
|
314 | 314 | $this->afterCompile[$index]=$callback; |
315 | 315 | return $this; |
316 | 316 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
27 | - $this->setInstance($instance); |
|
26 | + if(isset($instance)) { |
|
27 | + $this->setInstance($instance); |
|
28 | + } |
|
28 | 29 | $this->setCaptions($captions); |
29 | 30 | $this->captionCallback=NULL; |
30 | 31 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -62,14 +63,16 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | public function getIdentifier($index=NULL){ |
65 | - if(!isset($index)) |
|
66 | - $index=self::$index; |
|
66 | + if(!isset($index)) { |
|
67 | + $index=self::$index; |
|
68 | + } |
|
67 | 69 | $value=$index; |
68 | 70 | if(isset($this->values["identifier"])){ |
69 | - if(\is_string($this->values["identifier"])) |
|
70 | - $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
71 | - else |
|
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
71 | + if(\is_string($this->values["identifier"])) { |
|
72 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
73 | + } else { |
|
74 | + $value=$this->values["identifier"]($index,$this->instance); |
|
75 | + } |
|
73 | 76 | } |
74 | 77 | return $value; |
75 | 78 | } |
@@ -99,16 +102,16 @@ discard block |
||
99 | 102 | if($property instanceof \ReflectionProperty){ |
100 | 103 | $value=$this->_getPropertyValue($property, $index); |
101 | 104 | $propertyName=$property->getName(); |
102 | - }elseif(\is_callable($property)) |
|
103 | - $value=$property($this->instance); |
|
104 | - elseif(\is_array($property)){ |
|
105 | + } elseif(\is_callable($property)) { |
|
106 | + $value=$property($this->instance); |
|
107 | + } elseif(\is_array($property)){ |
|
105 | 108 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
106 | 109 | $value=\implode("", $values); |
107 | - }elseif(\is_string($property)){ |
|
110 | + } elseif(\is_string($property)){ |
|
108 | 111 | $value=$property; |
109 | 112 | if(isset($this->instance->{$property})){ |
110 | 113 | $value=$this->instance->{$property}; |
111 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
114 | + } elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
112 | 115 | $value=JReflection::callMethod($this->instance, $getter, []); |
113 | 116 | } |
114 | 117 | } |
@@ -118,7 +121,7 @@ discard block |
||
118 | 121 | protected function _postGetValue($index,$propertyName,$value){ |
119 | 122 | if(isset($this->values[$index])){ |
120 | 123 | $value= $this->values[$index]($value,$this->instance,$index); |
121 | - }else{ |
|
124 | + } else{ |
|
122 | 125 | $value=$this->_getDefaultValue($propertyName,$value, $index); |
123 | 126 | } |
124 | 127 | if(isset($this->afterCompile[$index])){ |
@@ -139,10 +142,10 @@ discard block |
||
139 | 142 | if(isset($vb[$index])){ |
140 | 143 | if(\is_array($vb[$index])){ |
141 | 144 | $this->visibleProperties[$index][]=$field; |
142 | - }else{ |
|
145 | + } else{ |
|
143 | 146 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
144 | 147 | } |
145 | - }else{ |
|
148 | + } else{ |
|
146 | 149 | return $this->insertField($index, $field); |
147 | 150 | } |
148 | 151 | return $this; |
@@ -169,9 +172,9 @@ discard block |
||
169 | 172 | $property=$this->getProperty($index); |
170 | 173 | if($property instanceof \ReflectionProperty){ |
171 | 174 | $result=$property->getName(); |
172 | - }elseif(\is_callable($property)){ |
|
175 | + } elseif(\is_callable($property)){ |
|
173 | 176 | $result=$this->visibleProperties[$index]; |
174 | - }else{ |
|
177 | + } else{ |
|
175 | 178 | $result=$property; |
176 | 179 | } |
177 | 180 | return $result; |
@@ -191,7 +194,7 @@ discard block |
||
191 | 194 | $this->reflect=new \ReflectionClass($instance); |
192 | 195 | if(\sizeof($this->visibleProperties)===0){ |
193 | 196 | $this->properties=$this->getDefaultProperties(); |
194 | - }else{ |
|
197 | + } else{ |
|
195 | 198 | foreach ($this->visibleProperties as $property){ |
196 | 199 | $this->setInstanceProperty($property); |
197 | 200 | } |
@@ -202,22 +205,23 @@ discard block |
||
202 | 205 | private function setInstanceProperty($property){ |
203 | 206 | if(\is_callable($property)){ |
204 | 207 | $this->properties[]=$property; |
205 | - }elseif(\is_string($property)){ |
|
208 | + } elseif(\is_string($property)){ |
|
206 | 209 | try{ |
207 | 210 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
208 | 211 | $rProperty=$this->reflect->getProperty($property); |
209 | 212 | $this->properties[]=$rProperty; |
210 | - }catch(\Exception $e){ |
|
213 | + } catch(\Exception $e){ |
|
211 | 214 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
212 | 215 | $this->properties[]=$property; |
213 | 216 | } |
214 | - }elseif(\is_int($property)){ |
|
217 | + } elseif(\is_int($property)){ |
|
215 | 218 | $props=$this->getDefaultProperties(); |
216 | - if(isset($props[$property])) |
|
217 | - $this->properties[]=$props[$property]; |
|
218 | - else |
|
219 | - $this->properties[]=$property; |
|
220 | - }else{ |
|
219 | + if(isset($props[$property])) { |
|
220 | + $this->properties[]=$props[$property]; |
|
221 | + } else { |
|
222 | + $this->properties[]=$property; |
|
223 | + } |
|
224 | + } else{ |
|
221 | 225 | $this->properties[]=$property; |
222 | 226 | } |
223 | 227 | } |
@@ -261,12 +265,13 @@ discard block |
||
261 | 265 | if(isset($this->captions[$index])){ |
262 | 266 | return $this->captions[$index]; |
263 | 267 | } |
264 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
265 | - return $this->properties[$index]->getName(); |
|
266 | - elseif(\is_callable($this->properties[$index])) |
|
267 | - return ""; |
|
268 | - else |
|
269 | - return $this->properties[$index]; |
|
268 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
269 | + return $this->properties[$index]->getName(); |
|
270 | + } elseif(\is_callable($this->properties[$index])) { |
|
271 | + return ""; |
|
272 | + } else { |
|
273 | + return $this->properties[$index]; |
|
274 | + } |
|
270 | 275 | } |
271 | 276 | |
272 | 277 | public function getCaptions(){ |
@@ -276,7 +281,7 @@ discard block |
||
276 | 281 | for($i=$captionsSize;$i<$this->count();$i++){ |
277 | 282 | $captions[]=""; |
278 | 283 | } |
279 | - }else{ |
|
284 | + } else{ |
|
280 | 285 | $captions=[]; |
281 | 286 | $index=0; |
282 | 287 | $count=$this->count(); |
@@ -292,8 +297,9 @@ discard block |
||
292 | 297 | } |
293 | 298 | |
294 | 299 | public function setCaption($index,$caption){ |
295 | - if(isset($this->captions)===false) |
|
296 | - $this->captions=[]; |
|
300 | + if(isset($this->captions)===false) { |
|
301 | + $this->captions=[]; |
|
302 | + } |
|
297 | 303 | $this->captions[$index]=$caption; |
298 | 304 | return $this; |
299 | 305 | } |