@@ -15,18 +15,20 @@ discard block |
||
| 15 | 15 | public function __construct($instance=NULL,$captions=NULL){ |
| 16 | 16 | $this->values=[]; |
| 17 | 17 | $this->afterCompile=[]; |
| 18 | - if(isset($instance)) |
|
| 19 | - $this->setInstance($instance); |
|
| 18 | + if(isset($instance)) { |
|
| 19 | + $this->setInstance($instance); |
|
| 20 | + } |
|
| 20 | 21 | $this->setCaptions($captions); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | 24 | public function getCaption($index){ |
| 24 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 25 | - return $this->properties[$index]->getName(); |
|
| 26 | - elseif(\is_callable($this->properties[$index])) |
|
| 27 | - return ""; |
|
| 28 | - else |
|
| 29 | - return $this->properties[$index]; |
|
| 25 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 26 | + return $this->properties[$index]->getName(); |
|
| 27 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 28 | + return ""; |
|
| 29 | + } else { |
|
| 30 | + return $this->properties[$index]; |
|
| 31 | + } |
|
| 30 | 32 | } |
| 31 | 33 | |
| 32 | 34 | public function getCaptions(){ |
@@ -58,8 +60,9 @@ discard block |
||
| 58 | 60 | |
| 59 | 61 | public function getIdentifier(){ |
| 60 | 62 | $value=self::$index; |
| 61 | - if(isset($this->values["identifier"])) |
|
| 62 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 63 | + if(isset($this->values["identifier"])) { |
|
| 64 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 65 | + } |
|
| 63 | 66 | self::$index++; |
| 64 | 67 | return $value; |
| 65 | 68 | } |
@@ -76,14 +79,15 @@ discard block |
||
| 76 | 79 | if(isset($this->values[$index])){ |
| 77 | 80 | $value= $this->values[$index]($value); |
| 78 | 81 | } |
| 79 | - }else{ |
|
| 80 | - if(\is_callable($property)) |
|
| 81 | - $value=$property($this->instance); |
|
| 82 | - elseif(\is_array($property)){ |
|
| 82 | + } else{ |
|
| 83 | + if(\is_callable($property)) { |
|
| 84 | + $value=$property($this->instance); |
|
| 85 | + } elseif(\is_array($property)){ |
|
| 83 | 86 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 84 | 87 | $value=\implode("", $values); |
| 85 | - }else |
|
| 86 | - $value=$property; |
|
| 88 | + } else { |
|
| 89 | + $value=$property; |
|
| 90 | + } |
|
| 87 | 91 | } |
| 88 | 92 | if(isset($this->afterCompile[$index])){ |
| 89 | 93 | if(\is_callable($this->afterCompile[$index])){ |
@@ -103,10 +107,10 @@ discard block |
||
| 103 | 107 | if(isset($vb[$index])){ |
| 104 | 108 | if(\is_array($vb[$index])){ |
| 105 | 109 | $this->visibleProperties[$index][]=$field; |
| 106 | - }else{ |
|
| 110 | + } else{ |
|
| 107 | 111 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 108 | 112 | } |
| 109 | - }else{ |
|
| 113 | + } else{ |
|
| 110 | 114 | return $this->insertField($index, $field); |
| 111 | 115 | } |
| 112 | 116 | return $this; |
@@ -138,24 +142,25 @@ discard block |
||
| 138 | 142 | $this->reflect=new \ReflectionClass($instance); |
| 139 | 143 | if(\sizeof($this->visibleProperties)===0){ |
| 140 | 144 | $this->properties=$this->getDefaultProperties(); |
| 141 | - }else{ |
|
| 145 | + } else{ |
|
| 142 | 146 | foreach ($this->visibleProperties as $property){ |
| 143 | 147 | if(\is_callable($property)){ |
| 144 | 148 | $this->properties[]=$property; |
| 145 | - }elseif(\is_string($property)){ |
|
| 149 | + } elseif(\is_string($property)){ |
|
| 146 | 150 | try{ |
| 147 | 151 | $rProperty=$this->reflect->getProperty($property); |
| 148 | 152 | $this->properties[]=$rProperty; |
| 149 | - }catch(\Exception $e){ |
|
| 153 | + } catch(\Exception $e){ |
|
| 150 | 154 | $this->properties[]=$property; |
| 151 | 155 | } |
| 152 | - }elseif(\is_int($property)){ |
|
| 156 | + } elseif(\is_int($property)){ |
|
| 153 | 157 | $props=$this->getDefaultProperties(); |
| 154 | - if(isset($props[$property])) |
|
| 155 | - $this->properties[]=$props[$property]; |
|
| 156 | - else |
|
| 157 | - $this->properties[]=$property; |
|
| 158 | - }else{ |
|
| 158 | + if(isset($props[$property])) { |
|
| 159 | + $this->properties[]=$props[$property]; |
|
| 160 | + } else { |
|
| 161 | + $this->properties[]=$property; |
|
| 162 | + } |
|
| 163 | + } else{ |
|
| 159 | 164 | $this->properties[]=$property; |
| 160 | 165 | } |
| 161 | 166 | } |