@@ -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 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | $class = (new \ReflectionClass($object))->getProperties(); |
25 | 25 | |
26 | - if($parent == false) |
|
26 | + if ($parent == false) |
|
27 | 27 | $class = (new \ReflectionClass($object))->getParentClass()->getProperties(); |
28 | 28 | |
29 | 29 | foreach ($class as $property) { |
@@ -102,7 +102,7 @@ |
||
102 | 102 | if ($this->value instanceof MappableModelInterface) { |
103 | 103 | return $this->value->getId(); |
104 | 104 | } |
105 | - else if($this->value instanceof \DateTime){ |
|
105 | + else if ($this->value instanceof \DateTime) { |
|
106 | 106 | return $this->value->format('Y-m-d'); |
107 | 107 | } |
108 | 108 | return $this->value; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $this->lazy = $lazy; |
75 | 75 | |
76 | 76 | // Se não for lazy load, carrega o objeto |
77 | - if(!$this->lazy) |
|
77 | + if (!$this->lazy) |
|
78 | 78 | $this->populate($this->where); |
79 | 79 | } |
80 | 80 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function __call($name, $arg) |
91 | 91 | { |
92 | 92 | // Carrega o objeto se por lazy load |
93 | - if($this->lazy) |
|
93 | + if ($this->lazy) |
|
94 | 94 | $this->populate($this->where); |
95 | 95 | } |
96 | 96 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | // Se for numérico ou string, presume-se |
127 | 127 | // que é uma chave primária. |
128 | - if(is_numeric($param) || is_string($param)) |
|
128 | + if (is_numeric($param) || is_string($param)) |
|
129 | 129 | { |
130 | 130 | $this->populateFromId($param); |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | // Verifica se é um comando do tipo where |
134 | 134 | // que pode ser usado diretamente como parâmetro |
135 | 135 | // no TableGateway do Zend Framework 2. |
136 | - else if(!is_null($param)) |
|
136 | + else if (!is_null($param)) |
|
137 | 137 | { |
138 | 138 | $this->populateFromWhere($param); |
139 | 139 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | private function populateFromId($id) |
152 | 152 | { |
153 | - if(empty($this->primaryKey)) |
|
153 | + if (empty($this->primaryKey)) |
|
154 | 154 | throw new NoPrimaryKeyException(); |
155 | 155 | |
156 | 156 | $this->populateFromWhere([$this->primaryKey => $id]); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | $resultSet = $this->tableGateway->select($where); |
171 | 171 | |
172 | - if($resultSet->count() === 0) |
|
172 | + if ($resultSet->count() === 0) |
|
173 | 173 | throw new NoDataFoundException(); |
174 | 174 | |
175 | 175 | $array = $resultSet->toArray()[0]; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * Método a ser executado antes de salvar o objeto. |
181 | 181 | * @return mixed |
182 | 182 | */ |
183 | - protected function beforeSave(){} |
|
183 | + protected function beforeSave() {} |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Método responsável por salvar um objeto no banco de dados |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function save($callBeforeSave = true) |
194 | 194 | { |
195 | - if($callBeforeSave) { |
|
195 | + if ($callBeforeSave) { |
|
196 | 196 | $this->beforeSave(); |
197 | 197 | $this->tableGateway = new TableGateway($this, Reader::getConfig($this)['table']); |
198 | 198 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->tableGateway = new TableGateway($this, Reader::getConfig($this)['parent']); |
202 | 202 | } |
203 | 203 | |
204 | - if(empty($this->getId())) |
|
204 | + if (empty($this->getId())) |
|
205 | 205 | { |
206 | 206 | return $this->insert($callBeforeSave); |
207 | 207 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | $table = new TableGateway(self::getInstance(), Reader::getConfig(self::getInstance())['table']); |
227 | 227 | $resultSet = $table->select($where); |
228 | 228 | |
229 | - if($resultSet->count() === 0) |
|
229 | + if ($resultSet->count() === 0) |
|
230 | 230 | throw new NoDataFoundException(); |
231 | 231 | |
232 | 232 | $list = new ArrayList(); |
233 | 233 | |
234 | - foreach($resultSet->toArray() as $array) |
|
234 | + foreach ($resultSet->toArray() as $array) |
|
235 | 235 | { |
236 | 236 | $obj = self::getInstance(); |
237 | 237 | Populator::populate($obj, $array); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $this->tableGateway->insert(Extractor::extract($this, $parent)); |
255 | 255 | $id = $this->tableGateway->getLastInsertValue(); |
256 | 256 | |
257 | - if($parent) |
|
257 | + if ($parent) |
|
258 | 258 | $this->setId($id); |
259 | 259 | |
260 | 260 | return $id; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | { |
289 | 289 | $this->tableGateway = new TableGateway($this); |
290 | 290 | |
291 | - if(!empty($this->primaryKey)) |
|
291 | + if (!empty($this->primaryKey)) |
|
292 | 292 | { |
293 | 293 | return $this->tableGateway->delete([$this->primaryKey => $this->getId()]); |
294 | 294 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->table = $this->config['table']; |
30 | 30 | |
31 | - if(!isset($this->config['adapter'])) |
|
31 | + if (!isset($this->config['adapter'])) |
|
32 | 32 | $this->config['adapter'] = 'Default'; |
33 | 33 | |
34 | 34 | $adapterPool = new AdapterPool(); |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | $this->updateContext(); |
38 | 38 | |
39 | 39 | $platform = $this->adapter->getPlatform()->getName(); |
40 | - if(isset($this->config['schema']) && $platform == 'PostgreSQL'){ |
|
40 | + if (isset($this->config['schema']) && $platform == 'PostgreSQL') { |
|
41 | 41 | $pk = $this->config['primary_key']; |
42 | - $sq = $this->config['table'] . '_' . $pk . '_seq'; |
|
42 | + $sq = $this->config['table'].'_'.$pk.'_seq'; |
|
43 | 43 | |
44 | 44 | $this->featureSet = new FeatureSet(); |
45 | 45 | $this->featureSet->addFeature(new SequenceFeature($pk, $sq)); |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | { |
52 | 52 | $platform = $this->adapter->getPlatform()->getName(); |
53 | 53 | |
54 | - if(isset($this->config['schema']) && $platform == 'MySQL'){ |
|
55 | - $sql = 'USE ' . $this->config['schema'] . ';'; |
|
54 | + if (isset($this->config['schema']) && $platform == 'MySQL') { |
|
55 | + $sql = 'USE '.$this->config['schema'].';'; |
|
56 | 56 | $this->adapter->getDriver()->getConnection()->execute($sql); |
57 | 57 | |
58 | 58 | $sql = 'SET FOREIGN_KEY_CHECKS = FALSE;'; |
59 | 59 | $this->adapter->getDriver()->getConnection()->execute($sql); |
60 | 60 | } |
61 | 61 | |
62 | - if(isset($this->config['schema']) && $platform == 'PostgreSQL'){ |
|
63 | - $sql = 'SET SCHEMA \'' . $this->config['schema'] . '\';'; |
|
62 | + if (isset($this->config['schema']) && $platform == 'PostgreSQL') { |
|
63 | + $sql = 'SET SCHEMA \''.$this->config['schema'].'\';'; |
|
64 | 64 | $this->adapter->getDriver()->getConnection()->execute($sql); |
65 | 65 | } |
66 | 66 | } |