@@ -74,8 +74,9 @@ discard block |
||
74 | 74 | $this->lazy = $lazy; |
75 | 75 | |
76 | 76 | // Se não for lazy load, carrega o objeto |
77 | - if(!$this->lazy) |
|
78 | - $this->populate($this->where); |
|
77 | + if(!$this->lazy) { |
|
78 | + $this->populate($this->where); |
|
79 | + } |
|
79 | 80 | } |
80 | 81 | |
81 | 82 | /** |
@@ -90,8 +91,9 @@ discard block |
||
90 | 91 | public function __call($name, $arg) |
91 | 92 | { |
92 | 93 | // Carrega o objeto se por lazy load |
93 | - if($this->lazy) |
|
94 | - $this->populate($this->where); |
|
94 | + if($this->lazy) { |
|
95 | + $this->populate($this->where); |
|
96 | + } |
|
95 | 97 | } |
96 | 98 | |
97 | 99 | /** |
@@ -150,8 +152,9 @@ discard block |
||
150 | 152 | */ |
151 | 153 | private function populateFromId($id) |
152 | 154 | { |
153 | - if(empty($this->primaryKey)) |
|
154 | - throw new NoPrimaryKeyException(); |
|
155 | + if(empty($this->primaryKey)) { |
|
156 | + throw new NoPrimaryKeyException(); |
|
157 | + } |
|
155 | 158 | |
156 | 159 | $this->populateFromWhere([$this->primaryKey => $id]); |
157 | 160 | } |
@@ -169,8 +172,9 @@ discard block |
||
169 | 172 | { |
170 | 173 | $resultSet = $this->tableGateway->select($where); |
171 | 174 | |
172 | - if($resultSet->count() === 0) |
|
173 | - throw new NoDataFoundException(); |
|
175 | + if($resultSet->count() === 0) { |
|
176 | + throw new NoDataFoundException(); |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $array = $resultSet->toArray()[0]; |
176 | 180 | Populator::populate($this, $array); |
@@ -195,8 +199,7 @@ discard block |
||
195 | 199 | if($callBeforeSave) { |
196 | 200 | $this->beforeSave(); |
197 | 201 | $this->tableGateway = new TableGateway($this, Reader::getConfig($this)['table']); |
198 | - } |
|
199 | - else |
|
202 | + } else |
|
200 | 203 | { |
201 | 204 | $this->tableGateway = new TableGateway($this, Reader::getConfig($this)['parent']); |
202 | 205 | } |
@@ -204,8 +207,7 @@ discard block |
||
204 | 207 | if(empty($this->getId())) |
205 | 208 | { |
206 | 209 | return $this->insert($callBeforeSave); |
207 | - } |
|
208 | - else |
|
210 | + } else |
|
209 | 211 | { |
210 | 212 | return $this->update(); |
211 | 213 | } |
@@ -226,8 +228,9 @@ discard block |
||
226 | 228 | $table = new TableGateway(self::getInstance(), Reader::getConfig(self::getInstance())['table']); |
227 | 229 | $resultSet = $table->select($where); |
228 | 230 | |
229 | - if($resultSet->count() === 0) |
|
230 | - throw new NoDataFoundException(); |
|
231 | + if($resultSet->count() === 0) { |
|
232 | + throw new NoDataFoundException(); |
|
233 | + } |
|
231 | 234 | |
232 | 235 | $list = new Vector(); |
233 | 236 | |
@@ -254,8 +257,9 @@ discard block |
||
254 | 257 | $this->tableGateway->insert(Extractor::extract($this, $parent)); |
255 | 258 | $id = $this->tableGateway->getLastInsertValue(); |
256 | 259 | |
257 | - if($parent) |
|
258 | - $this->setId($id); |
|
260 | + if($parent) { |
|
261 | + $this->setId($id); |
|
262 | + } |
|
259 | 263 | |
260 | 264 | return $id; |
261 | 265 | } |
@@ -291,8 +295,7 @@ discard block |
||
291 | 295 | if(!empty($this->primaryKey)) |
292 | 296 | { |
293 | 297 | return $this->tableGateway->delete([$this->primaryKey => $this->getId()]); |
294 | - } |
|
295 | - else |
|
298 | + } else |
|
296 | 299 | { |
297 | 300 | return $this->tableGateway->delete(Extractor::extract($this)); |
298 | 301 | } |