@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | public function __construct($instance=NULL,$captions=NULL){ |
18 | 18 | $this->values=[]; |
19 | 19 | $this->afterCompile=[]; |
20 | - if(isset($instance)) |
|
21 | - $this->setInstance($instance); |
|
20 | + if(isset($instance)) { |
|
21 | + $this->setInstance($instance); |
|
22 | + } |
|
22 | 23 | $this->setCaptions($captions); |
23 | 24 | } |
24 | 25 | |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | public function getIdentifier(){ |
36 | 37 | $value=self::$index; |
37 | - if(isset($this->values["identifier"])) |
|
38 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
38 | + if(isset($this->values["identifier"])) { |
|
39 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
40 | + } |
|
39 | 41 | return $value; |
40 | 42 | } |
41 | 43 | |
@@ -51,14 +53,15 @@ discard block |
||
51 | 53 | if(isset($this->values[$index])){ |
52 | 54 | $value= $this->values[$index]($value); |
53 | 55 | } |
54 | - }else{ |
|
55 | - if(\is_callable($property)) |
|
56 | - $value=$property($this->instance); |
|
57 | - elseif(\is_array($property)){ |
|
56 | + } else{ |
|
57 | + if(\is_callable($property)) { |
|
58 | + $value=$property($this->instance); |
|
59 | + } elseif(\is_array($property)){ |
|
58 | 60 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
59 | 61 | $value=\implode("", $values); |
60 | - }else |
|
61 | - $value=$property; |
|
62 | + } else { |
|
63 | + $value=$property; |
|
64 | + } |
|
62 | 65 | } |
63 | 66 | if(isset($this->afterCompile[$index])){ |
64 | 67 | if(\is_callable($this->afterCompile[$index])){ |
@@ -78,10 +81,10 @@ discard block |
||
78 | 81 | if(isset($vb[$index])){ |
79 | 82 | if(\is_array($vb[$index])){ |
80 | 83 | $this->visibleProperties[$index][]=$field; |
81 | - }else{ |
|
84 | + } else{ |
|
82 | 85 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
83 | 86 | } |
84 | - }else{ |
|
87 | + } else{ |
|
85 | 88 | return $this->insertField($index, $field); |
86 | 89 | } |
87 | 90 | return $this; |
@@ -113,24 +116,25 @@ discard block |
||
113 | 116 | $this->reflect=new \ReflectionClass($instance); |
114 | 117 | if(\sizeof($this->visibleProperties)===0){ |
115 | 118 | $this->properties=$this->getDefaultProperties(); |
116 | - }else{ |
|
119 | + } else{ |
|
117 | 120 | foreach ($this->visibleProperties as $property){ |
118 | 121 | if(\is_callable($property)){ |
119 | 122 | $this->properties[]=$property; |
120 | - }elseif(\is_string($property)){ |
|
123 | + } elseif(\is_string($property)){ |
|
121 | 124 | try{ |
122 | 125 | $rProperty=$this->reflect->getProperty($property); |
123 | 126 | $this->properties[]=$rProperty; |
124 | - }catch(\Exception $e){ |
|
127 | + } catch(\Exception $e){ |
|
125 | 128 | $this->properties[]=$property; |
126 | 129 | } |
127 | - }elseif(\is_int($property)){ |
|
130 | + } elseif(\is_int($property)){ |
|
128 | 131 | $props=$this->getDefaultProperties(); |
129 | - if(isset($props[$property])) |
|
130 | - $this->properties[]=$props[$property]; |
|
131 | - else |
|
132 | - $this->properties[]=$property; |
|
133 | - }else{ |
|
132 | + if(isset($props[$property])) { |
|
133 | + $this->properties[]=$props[$property]; |
|
134 | + } else { |
|
135 | + $this->properties[]=$property; |
|
136 | + } |
|
137 | + } else{ |
|
134 | 138 | $this->properties[]=$property; |
135 | 139 | } |
136 | 140 | } |
@@ -174,12 +178,13 @@ discard block |
||
174 | 178 | } |
175 | 179 | |
176 | 180 | public function getCaption($index){ |
177 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
178 | - return $this->properties[$index]->getName(); |
|
179 | - elseif(\is_callable($this->properties[$index])) |
|
180 | - return ""; |
|
181 | - else |
|
182 | - return $this->properties[$index]; |
|
181 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
182 | + return $this->properties[$index]->getName(); |
|
183 | + } elseif(\is_callable($this->properties[$index])) { |
|
184 | + return ""; |
|
185 | + } else { |
|
186 | + return $this->properties[$index]; |
|
187 | + } |
|
183 | 188 | } |
184 | 189 | |
185 | 190 | public function getCaptions(){ |