@@ -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 | } |