| @@ -63,17 +63,21 @@ discard block | ||
| 63 | 63 | $this->setName($property->getName()); | 
| 64 | 64 | $this->setValue($property->getValue($object)); | 
| 65 | 65 | |
| 66 | -        if (array_key_exists('alias', $config)) | |
| 67 | - $this->setAlias($config['alias']); | |
| 66 | +        if (array_key_exists('alias', $config)) { | |
| 67 | + $this->setAlias($config['alias']); | |
| 68 | + } | |
| 68 | 69 | |
| 69 | -        if (array_key_exists('ignore', $config)) | |
| 70 | - $this->setIgnore($config['ignore']); | |
| 70 | +        if (array_key_exists('ignore', $config)) { | |
| 71 | + $this->setIgnore($config['ignore']); | |
| 72 | + } | |
| 71 | 73 | |
| 72 | -        if (array_key_exists('ignoreIfNull', $config)) | |
| 73 | - $this->setIgnoreIfNull($config['ignoreIfNull']); | |
| 74 | +        if (array_key_exists('ignoreIfNull', $config)) { | |
| 75 | + $this->setIgnoreIfNull($config['ignoreIfNull']); | |
| 76 | + } | |
| 74 | 77 | |
| 75 | -        if (array_key_exists('type', $config)) | |
| 76 | - $this->setType($config['type']); | |
| 78 | +        if (array_key_exists('type', $config)) { | |
| 79 | + $this->setType($config['type']); | |
| 80 | + } | |
| 77 | 81 | } | 
| 78 | 82 | |
| 79 | 83 | /** | 
| @@ -179,8 +183,9 @@ discard block | ||
| 179 | 183 | */ | 
| 180 | 184 | public function getAlias() | 
| 181 | 185 |      { | 
| 182 | - if (!empty($this->alias)) | |
| 183 | - return $this->alias; | |
| 186 | +        if (!empty($this->alias)) { | |
| 187 | + return $this->alias; | |
| 188 | + } | |
| 184 | 189 | |
| 185 | 190 | return $this->name; | 
| 186 | 191 | } | 
| @@ -18,8 +18,9 @@ | ||
| 18 | 18 |      { | 
| 19 | 19 | $config = Reader::getConfig($object); | 
| 20 | 20 | |
| 21 | -        if (!array_key_exists('table', $config)) | |
| 22 | - throw new NoTableFoundException(); | |
| 21 | +        if (!array_key_exists('table', $config)) { | |
| 22 | + throw new NoTableFoundException(); | |
| 23 | + } | |
| 23 | 24 | |
| 24 | 25 | $this->table = $config['table']; | 
| 25 | 26 | $this->adapter = GlobalAdapterFeature::getStaticAdapter(); | 
| @@ -24,8 +24,9 @@ | ||
| 24 | 24 |          foreach ((new \ReflectionClass($object))->getProperties() as $property) { | 
| 25 | 25 | $config = new PropertyConfiguration($property, $object); | 
| 26 | 26 | |
| 27 | - if ($config->ignore() || $config->shouldIgnoreIfNull()) | |
| 28 | - continue; | |
| 27 | +            if ($config->ignore() || $config->shouldIgnoreIfNull()) { | |
| 28 | + continue; | |
| 29 | + } | |
| 29 | 30 | |
| 30 | 31 | $name = $config->getAlias(); | 
| 31 | 32 | $data = $config->getValue(); | 
| @@ -59,7 +59,7 @@ discard block | ||
| 59 | 59 | if (array_key_exists($alias, $array)) | 
| 60 | 60 | $value = $array[$alias]; | 
| 61 | 61 | |
| 62 | - if(!empty($configuration->getType())) | |
| 62 | + if (!empty($configuration->getType())) | |
| 63 | 63 |          { | 
| 64 | 64 | $type = $configuration->getType(); | 
| 65 | 65 | |
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 |              { | 
| 68 | 68 | $value = new $type($value, false); | 
| 69 | 69 | } | 
| 70 | - catch(NoDataFoundException $e) | |
| 70 | + catch (NoDataFoundException $e) | |
| 71 | 71 |              { | 
| 72 | 72 | $value = new $type(); | 
| 73 | 73 | } | 
| @@ -50,14 +50,16 @@ discard block | ||
| 50 | 50 | |
| 51 | 51 | // Se o campo for do tipo que deve ser ignorado, | 
| 52 | 52 | // não meche nele... | 
| 53 | - if ($configuration->ignore()) | |
| 54 | - return; | |
| 53 | +        if ($configuration->ignore()) { | |
| 54 | + return; | |
| 55 | + } | |
| 55 | 56 | |
| 56 | 57 | $value = null; | 
| 57 | 58 | $alias = $configuration->getAlias(); | 
| 58 | 59 | |
| 59 | - if (array_key_exists($alias, $array)) | |
| 60 | - $value = $array[$alias]; | |
| 60 | +        if (array_key_exists($alias, $array)) { | |
| 61 | + $value = $array[$alias]; | |
| 62 | + } | |
| 61 | 63 | |
| 62 | 64 | if(!empty($configuration->getType())) | 
| 63 | 65 |          { | 
| @@ -66,8 +68,7 @@ discard block | ||
| 66 | 68 | try | 
| 67 | 69 |              { | 
| 68 | 70 | $value = new $type($value, false); | 
| 69 | - } | |
| 70 | - catch(NoDataFoundException $e) | |
| 71 | + } catch(NoDataFoundException $e) | |
| 71 | 72 |              { | 
| 72 | 73 | $value = new $type(); | 
| 73 | 74 | } | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | $this->lazy = $lazy; | 
| 69 | 69 | |
| 70 | 70 | // Se não for lazy load, carrega o objeto | 
| 71 | - if(!$this->lazy) | |
| 71 | + if (!$this->lazy) | |
| 72 | 72 | $this->populate($this->where); | 
| 73 | 73 | } | 
| 74 | 74 | |
| @@ -84,7 +84,7 @@ discard block | ||
| 84 | 84 | public function __call($name, $arg) | 
| 85 | 85 |      { | 
| 86 | 86 | // Carrega o objeto se por lazy load | 
| 87 | - if($this->lazy) | |
| 87 | + if ($this->lazy) | |
| 88 | 88 | $this->populate($this->where); | 
| 89 | 89 | } | 
| 90 | 90 | |
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 |      { | 
| 102 | 102 | // Se for numérico ou string, presume-se | 
| 103 | 103 | // que é uma chave primária. | 
| 104 | - if(is_numeric($param) || is_string($param)) | |
| 104 | + if (is_numeric($param) || is_string($param)) | |
| 105 | 105 |          { | 
| 106 | 106 | $this->populateFromId($param); | 
| 107 | 107 | } | 
| @@ -109,7 +109,7 @@ discard block | ||
| 109 | 109 | // Verifica se é um comando do tipo where | 
| 110 | 110 | // que pode ser usado diretamente como parâmetro | 
| 111 | 111 | // no TableGateway do Zend Framework 2. | 
| 112 | - else if(!is_null($param)) | |
| 112 | + else if (!is_null($param)) | |
| 113 | 113 |          { | 
| 114 | 114 | $this->populateFromWhere($param); | 
| 115 | 115 | } | 
| @@ -126,7 +126,7 @@ discard block | ||
| 126 | 126 | */ | 
| 127 | 127 | private function populateFromId($id) | 
| 128 | 128 |      { | 
| 129 | - if(empty($this->primaryKey)) | |
| 129 | + if (empty($this->primaryKey)) | |
| 130 | 130 | throw new NoPrimaryKeyException(); | 
| 131 | 131 | |
| 132 | 132 | $this->populateFromWhere([$this->primaryKey => $id]); | 
| @@ -145,7 +145,7 @@ discard block | ||
| 145 | 145 |      { | 
| 146 | 146 | $resultSet = $this->tableGateway->select($where); | 
| 147 | 147 | |
| 148 | - if($resultSet->count() == 0) | |
| 148 | + if ($resultSet->count() == 0) | |
| 149 | 149 | throw new NoDataFoundException(); | 
| 150 | 150 | |
| 151 | 151 | $array = $resultSet->toArray()[0]; | 
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 | */ | 
| 163 | 163 | public function save() | 
| 164 | 164 |      { | 
| 165 | - if(empty($this->getId())) | |
| 165 | + if (empty($this->getId())) | |
| 166 | 166 |          { | 
| 167 | 167 | return $this->insert(); | 
| 168 | 168 | } | 
| @@ -187,12 +187,12 @@ discard block | ||
| 187 | 187 | $table = new TableGateway(self::getInstance()); | 
| 188 | 188 | $resultSet = $table->select($where); | 
| 189 | 189 | |
| 190 | - if($resultSet->count() == 0) | |
| 190 | + if ($resultSet->count() == 0) | |
| 191 | 191 | throw new NoDataFoundException(); | 
| 192 | 192 | |
| 193 | 193 | $list = new ArrayList(); | 
| 194 | 194 | |
| 195 | - foreach($resultSet->toArray() as $array) | |
| 195 | + foreach ($resultSet->toArray() as $array) | |
| 196 | 196 |          { | 
| 197 | 197 | $obj = self::getInstance(); | 
| 198 | 198 | Populator::populate($obj, $array); | 
| @@ -241,7 +241,7 @@ discard block | ||
| 241 | 241 | */ | 
| 242 | 242 | public function delete() | 
| 243 | 243 |      { | 
| 244 | - if(!empty($this->primaryKey)) | |
| 244 | + if (!empty($this->primaryKey)) | |
| 245 | 245 |          { | 
| 246 | 246 | return $this->tableGateway->delete([$this->primaryKey => $this->getId()]); | 
| 247 | 247 | } | 
| @@ -68,8 +68,9 @@ discard block | ||
| 68 | 68 | $this->lazy = $lazy; | 
| 69 | 69 | |
| 70 | 70 | // Se não for lazy load, carrega o objeto | 
| 71 | - if(!$this->lazy) | |
| 72 | - $this->populate($this->where); | |
| 71 | +        if(!$this->lazy) { | |
| 72 | + $this->populate($this->where); | |
| 73 | + } | |
| 73 | 74 | } | 
| 74 | 75 | |
| 75 | 76 | /** | 
| @@ -84,8 +85,9 @@ discard block | ||
| 84 | 85 | public function __call($name, $arg) | 
| 85 | 86 |      { | 
| 86 | 87 | // Carrega o objeto se por lazy load | 
| 87 | - if($this->lazy) | |
| 88 | - $this->populate($this->where); | |
| 88 | +        if($this->lazy) { | |
| 89 | + $this->populate($this->where); | |
| 90 | + } | |
| 89 | 91 | } | 
| 90 | 92 | |
| 91 | 93 | /** | 
| @@ -126,8 +128,9 @@ discard block | ||
| 126 | 128 | */ | 
| 127 | 129 | private function populateFromId($id) | 
| 128 | 130 |      { | 
| 129 | - if(empty($this->primaryKey)) | |
| 130 | - throw new NoPrimaryKeyException(); | |
| 131 | +        if(empty($this->primaryKey)) { | |
| 132 | + throw new NoPrimaryKeyException(); | |
| 133 | + } | |
| 131 | 134 | |
| 132 | 135 | $this->populateFromWhere([$this->primaryKey => $id]); | 
| 133 | 136 | } | 
| @@ -145,8 +148,9 @@ discard block | ||
| 145 | 148 |      { | 
| 146 | 149 | $resultSet = $this->tableGateway->select($where); | 
| 147 | 150 | |
| 148 | - if($resultSet->count() == 0) | |
| 149 | - throw new NoDataFoundException(); | |
| 151 | +        if($resultSet->count() == 0) { | |
| 152 | + throw new NoDataFoundException(); | |
| 153 | + } | |
| 150 | 154 | |
| 151 | 155 | $array = $resultSet->toArray()[0]; | 
| 152 | 156 | Populator::populate($this, $array); | 
| @@ -165,8 +169,7 @@ discard block | ||
| 165 | 169 | if(empty($this->getId())) | 
| 166 | 170 |          { | 
| 167 | 171 | return $this->insert(); | 
| 168 | - } | |
| 169 | - else | |
| 172 | + } else | |
| 170 | 173 |          { | 
| 171 | 174 | return $this->update(); | 
| 172 | 175 | } | 
| @@ -187,8 +190,9 @@ discard block | ||
| 187 | 190 | $table = new TableGateway(self::getInstance()); | 
| 188 | 191 | $resultSet = $table->select($where); | 
| 189 | 192 | |
| 190 | - if($resultSet->count() == 0) | |
| 191 | - throw new NoDataFoundException(); | |
| 193 | +        if($resultSet->count() == 0) { | |
| 194 | + throw new NoDataFoundException(); | |
| 195 | + } | |
| 192 | 196 | |
| 193 | 197 | $list = new ArrayList(); | 
| 194 | 198 | |
| @@ -244,8 +248,7 @@ discard block | ||
| 244 | 248 | if(!empty($this->primaryKey)) | 
| 245 | 249 |          { | 
| 246 | 250 | return $this->tableGateway->delete([$this->primaryKey => $this->getId()]); | 
| 247 | - } | |
| 248 | - else | |
| 251 | + } else | |
| 249 | 252 |          { | 
| 250 | 253 | return $this->tableGateway->delete(Extractor::extract($this)); | 
| 251 | 254 | } |