@@ -34,28 +34,28 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var array |
36 | 36 | */ |
37 | - protected $entitys = []; |
|
37 | + protected $entitys = [ ]; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @var array |
41 | 41 | */ |
42 | - protected $tables = []; |
|
42 | + protected $tables = [ ]; |
|
43 | 43 | /** |
44 | 44 | * @var array |
45 | 45 | */ |
46 | - protected $queryFields = []; |
|
46 | + protected $queryFields = [ ]; |
|
47 | 47 | /** |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - protected $expressions = []; |
|
50 | + protected $expressions = [ ]; |
|
51 | 51 | /** |
52 | 52 | * @var array |
53 | 53 | */ |
54 | - protected $groupFields = []; |
|
54 | + protected $groupFields = [ ]; |
|
55 | 55 | /** |
56 | 56 | * @var array |
57 | 57 | */ |
58 | - protected $field = []; |
|
58 | + protected $field = [ ]; |
|
59 | 59 | /** |
60 | 60 | * @var int |
61 | 61 | */ |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @var array |
65 | 65 | */ |
66 | - protected $fieldValue = []; |
|
66 | + protected $fieldValue = [ ]; |
|
67 | 67 | |
68 | - public function __construct(RepositoryContract $repository) |
|
68 | + public function __construct (RepositoryContract $repository) |
|
69 | 69 | { |
70 | 70 | $this->repository = $repository; |
71 | 71 | $this->em = $this->repository->getEntityManager(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function getEntityName() |
|
81 | + public function getEntityName () |
|
82 | 82 | { |
83 | 83 | $this->repository->getEntityName(); |
84 | 84 | } |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - public function getPrimaryKeyEntity() |
|
91 | + public function getPrimaryKeyEntity () |
|
92 | 92 | { |
93 | - return $this->getClassMetaData()->identifier[0]; |
|
93 | + return $this->getClassMetaData()->identifier[ 0 ]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * @return Doctrine\ORM\Query |
98 | 98 | */ |
99 | - public function getQuery() |
|
99 | + public function getQuery () |
|
100 | 100 | { |
101 | 101 | $query = $this->queryBuilder->getQuery(); |
102 | 102 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function getResult() |
|
115 | + public function getResult () |
|
116 | 116 | { |
117 | 117 | $query = $this->getQuery(); |
118 | 118 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return Bludata\Doctrine\ORM\Entities\BaseEntity | null |
130 | 130 | */ |
131 | - public function getOneResult() |
|
131 | + public function getOneResult () |
|
132 | 132 | { |
133 | 133 | return $this->getQuery()->getOneOrNullResult(); |
134 | 134 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return array |
140 | 140 | */ |
141 | - public function toArray(array $options = null) |
|
141 | + public function toArray (array $options = null) |
|
142 | 142 | { |
143 | - $array = []; |
|
143 | + $array = [ ]; |
|
144 | 144 | |
145 | 145 | foreach ($this->getResult() as $item) { |
146 | 146 | if (method_exists($item, 'toArray')) { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * @return Doctrine\ORM\Mapping\ClassMetadata |
158 | 158 | */ |
159 | - public function getClassMetaData() |
|
159 | + public function getClassMetaData () |
|
160 | 160 | { |
161 | 161 | return $this->classMetadata; |
162 | 162 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | /** |
165 | 165 | * @return Doctrine\ORM\QueryBuilder |
166 | 166 | */ |
167 | - public function getBuilder() |
|
167 | + public function getBuilder () |
|
168 | 168 | { |
169 | 169 | return $this->queryBuilder; |
170 | 170 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @return QueryWorker |
174 | 174 | */ |
175 | - public function setBuilder($builder) |
|
175 | + public function setBuilder ($builder) |
|
176 | 176 | { |
177 | 177 | $this->queryBuilder = $builder; |
178 | 178 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return int |
186 | 186 | */ |
187 | - public function count() |
|
187 | + public function count () |
|
188 | 188 | { |
189 | 189 | return count($this->getResult()); |
190 | 190 | } |
@@ -196,40 +196,40 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return QueryWorker |
198 | 198 | */ |
199 | - public function withFilters(array $filters = null) |
|
199 | + public function withFilters (array $filters = null) |
|
200 | 200 | { |
201 | 201 | if ($filters) { |
202 | 202 | foreach ($filters as $filter) { |
203 | - switch ($filter['type']) { |
|
203 | + switch ($filter[ 'type' ]) { |
|
204 | 204 | case 'select': |
205 | - $this->select($filter['fields']); |
|
205 | + $this->select($filter[ 'fields' ]); |
|
206 | 206 | break; |
207 | 207 | case 'andWhere': |
208 | - $this->andWhere($filter['field'], $filter['operation'], $filter['value']); |
|
208 | + $this->andWhere($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]); |
|
209 | 209 | break; |
210 | 210 | case 'orWhere': |
211 | - $this->orWhere($filter['field'], $filter['operation'], $filter['value']); |
|
211 | + $this->orWhere($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]); |
|
212 | 212 | break; |
213 | 213 | case 'andHaving': |
214 | - $this->andHaving($filter['field'], $filter['operation'], $filter['value']); |
|
214 | + $this->andHaving($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]); |
|
215 | 215 | break; |
216 | 216 | case 'orHaving': |
217 | - $this->orHaving($filter['field'], $filter['operation'], $filter['value']); |
|
217 | + $this->orHaving($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]); |
|
218 | 218 | break; |
219 | 219 | case 'addGroupBy': |
220 | - $this->addGroupBy($filter['field']); |
|
220 | + $this->addGroupBy($filter[ 'field' ]); |
|
221 | 221 | break; |
222 | 222 | case 'addOrderBy': |
223 | - $this->addOrderBy($filter['field'], $filter['order']); |
|
223 | + $this->addOrderBy($filter[ 'field' ], $filter[ 'order' ]); |
|
224 | 224 | break; |
225 | 225 | case 'fkAddOrderBy': |
226 | - $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']); |
|
226 | + $this->fkAddOrderBy($filter[ 'field' ], $filter[ 'fkField' ], $filter[ 'order' ]); |
|
227 | 227 | break; |
228 | 228 | case 'paginate': |
229 | - if (isset($filter['page'])) { |
|
230 | - $this->paginate($filter['limit'], $filter['page']); |
|
229 | + if (isset($filter[ 'page' ])) { |
|
230 | + $this->paginate($filter[ 'limit' ], $filter[ 'page' ]); |
|
231 | 231 | } else { |
232 | - $this->paginate($filter['limit']); |
|
232 | + $this->paginate($filter[ 'limit' ]); |
|
233 | 233 | } |
234 | 234 | break; |
235 | 235 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return $this |
249 | 249 | */ |
250 | - public function paginate($limit = 25, $page = 0) |
|
250 | + public function paginate ($limit = 25, $page = 0) |
|
251 | 251 | { |
252 | 252 | if ($limit > 0) { |
253 | 253 | $this->queryBuilder->setMaxResults($limit); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return $this |
271 | 271 | */ |
272 | - public function andWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
272 | + public function andWhere ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
273 | 273 | { |
274 | 274 | if (strpos($field, '.') > 0) { |
275 | 275 | //monta os joins |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | 'operation' => $operation, |
279 | 279 | ]; |
280 | 280 | $newAliasField = $this->associationQueryFields($field); |
281 | - $alias = $newAliasField['alias']; |
|
282 | - $field = $newAliasField['field']; |
|
281 | + $alias = $newAliasField[ 'alias' ]; |
|
282 | + $field = $newAliasField[ 'field' ]; |
|
283 | 283 | } |
284 | 284 | $this->queryBuilder->andWhere($this->makeExpression($field, $operation, $value, $alias)); |
285 | 285 | |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return $this |
297 | 297 | */ |
298 | - public function orWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
298 | + public function orWhere ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
299 | 299 | { |
300 | 300 | if (strpos($field, '.') > 0) { |
301 | 301 | //monta os joins |
302 | 302 | $newAliasField = $this->associationQueryFields($field); |
303 | - $alias = $newAliasField['alias']; |
|
304 | - $field = $newAliasField['field']; |
|
303 | + $alias = $newAliasField[ 'alias' ]; |
|
304 | + $field = $newAliasField[ 'field' ]; |
|
305 | 305 | } |
306 | 306 | $this->queryBuilder->orWhere($this->makeExpression($field, $operation, $value, $alias)); |
307 | 307 | |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return $this |
317 | 317 | */ |
318 | - private function makeExpressions($conditions, $alias = self::DEFAULT_TABLE_ALIAS) |
|
318 | + private function makeExpressions ($conditions, $alias = self::DEFAULT_TABLE_ALIAS) |
|
319 | 319 | { |
320 | - $expressions = []; |
|
320 | + $expressions = [ ]; |
|
321 | 321 | foreach ($conditions as $attr) { |
322 | - $field = $attr['field']; |
|
322 | + $field = $attr[ 'field' ]; |
|
323 | 323 | if (strpos($field, '.') > 0) { |
324 | 324 | //monta os joins |
325 | 325 | $newAliasField = $this->associationQueryFields($field); |
326 | - $alias = $newAliasField['alias']; |
|
327 | - $field = $newAliasField['field']; |
|
326 | + $alias = $newAliasField[ 'alias' ]; |
|
327 | + $field = $newAliasField[ 'field' ]; |
|
328 | 328 | } |
329 | - $expressions[] = $this->makeExpression($field, $attr['operation'], $attr['value'], $alias); |
|
329 | + $expressions[ ] = $this->makeExpression($field, $attr[ 'operation' ], $attr[ 'value' ], $alias); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | return $expressions; |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @param string $field |
339 | 339 | */ |
340 | - public function addGroupBy($field) |
|
340 | + public function addGroupBy ($field) |
|
341 | 341 | { |
342 | 342 | $alias = self::DEFAULT_TABLE_ALIAS; |
343 | 343 | if (strpos($field, '.') > 0) { |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | } |
347 | 347 | if (count($this->queryFields) > 0) { |
348 | 348 | foreach ($this->queryFields as $item) { |
349 | - $parts = []; |
|
349 | + $parts = [ ]; |
|
350 | 350 | if (strpos($item, ' AS ')) { |
351 | 351 | $item = str_replace(')', '', str_replace('(', '', $item)); |
352 | 352 | $parts = explode('AS', $item); |
353 | - $item = trim($parts[0]); |
|
353 | + $item = trim($parts[ 0 ]); |
|
354 | 354 | } |
355 | 355 | if (!in_array($item, $this->groupFields)) { |
356 | 356 | $this->queryBuilder->addGroupBy($item); |
357 | - $this->groupFields[] = $item; |
|
357 | + $this->groupFields[ ] = $item; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return $this |
373 | 373 | */ |
374 | - public function andHaving($field, $operation, $value = null) |
|
374 | + public function andHaving ($field, $operation, $value = null) |
|
375 | 375 | { |
376 | 376 | throw new \Exception('Not implemented'); |
377 | 377 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @param string $field |
383 | 383 | */ |
384 | - public function orHaving($field, $operation, $value = null) |
|
384 | + public function orHaving ($field, $operation, $value = null) |
|
385 | 385 | { |
386 | 386 | throw new \Exception('Not implemented'); |
387 | 387 | } |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | * @param string $field |
393 | 393 | * @param string $order |
394 | 394 | */ |
395 | - public function addOrderBy($field, $order = 'ASC') |
|
395 | + public function addOrderBy ($field, $order = 'ASC') |
|
396 | 396 | { |
397 | 397 | $alias = self::DEFAULT_TABLE_ALIAS; |
398 | 398 | if (strpos($field, '.') > 0) { |
399 | 399 | //monta os joins |
400 | 400 | $newAliasField = $this->associationQueryFields($field); |
401 | - $alias = $newAliasField['alias']; |
|
402 | - $field = $newAliasField['field']; |
|
401 | + $alias = $newAliasField[ 'alias' ]; |
|
402 | + $field = $newAliasField[ 'field' ]; |
|
403 | 403 | } |
404 | 404 | $this->queryBuilder->addOrderBy($this->getFullFieldName($field, $alias), $order); |
405 | 405 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @param string $field |
413 | 413 | * @param string $order |
414 | 414 | */ |
415 | - public function fkAddOrderBy($field, $fkField, $order = 'ASC') |
|
415 | + public function fkAddOrderBy ($field, $fkField, $order = 'ASC') |
|
416 | 416 | { |
417 | 417 | $alias = $this->tableAlias(); |
418 | 418 | $this->queryBuilder->join($this->getFullFieldName($field), $alias); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | * @param associationField.fkField |
428 | 428 | * @param $field |
429 | 429 | */ |
430 | - public function select($fields) |
|
430 | + public function select ($fields) |
|
431 | 431 | { |
432 | 432 | foreach ($fields as $key => $value) { |
433 | 433 | if (is_int($key)) { |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | $alias = $this->tableAlias(); |
437 | 437 | $this->queryBuilder->join($this->getFullFieldName($key, self::DEFAULT_TABLE_ALIAS), $alias); |
438 | 438 | foreach ($value as $valueField) { |
439 | - $this->queryFields[] = $this->getFullFieldName($valueField, $alias); |
|
439 | + $this->queryFields[ ] = $this->getFullFieldName($valueField, $alias); |
|
440 | 440 | } |
441 | 441 | } else { |
442 | - $this->queryFields[] = $value; |
|
442 | + $this->queryFields[ ] = $value; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | $this->queryBuilder->select(implode(',', $this->queryFields)); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @param associationField.fkField |
454 | 454 | * @param $field |
455 | 455 | */ |
456 | - public function associationQueryFields($campo) |
|
456 | + public function associationQueryFields ($campo) |
|
457 | 457 | { |
458 | 458 | $this->field = $campo; |
459 | 459 | $pos = strpos($campo, '.'); |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | $arr = explode('.', $campo); |
462 | 462 | $lastField = end($arr); |
463 | 463 | |
464 | - if (count($arr) == 2 && $arr[0] == self::DEFAULT_TABLE_ALIAS) { |
|
464 | + if (count($arr) == 2 && $arr[ 0 ] == self::DEFAULT_TABLE_ALIAS) { |
|
465 | 465 | //não é um campo composto |
466 | 466 | return [ |
467 | 467 | 'field' => $lastField, |
468 | - 'alias' => $arr[0], |
|
468 | + 'alias' => $arr[ 0 ], |
|
469 | 469 | ]; |
470 | 470 | } |
471 | 471 | |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | if ($this->position < count($arr) - 1) { |
477 | 477 | $dados = $this->getMetaAndAliases(); |
478 | 478 | |
479 | - $alias = $dados['alias']; |
|
480 | - $parentAlias = $dados['parentAlias']; |
|
479 | + $alias = $dados[ 'alias' ]; |
|
480 | + $parentAlias = $dados[ 'parentAlias' ]; |
|
481 | 481 | |
482 | 482 | if ($tempMeta) { |
483 | 483 | $meta = $tempMeta; |
484 | 484 | $tempMeta = ''; |
485 | 485 | } else { |
486 | - $meta = $dados['parentMeta']; |
|
486 | + $meta = $dados[ 'parentMeta' ]; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | if ($meta->isAssociationWithSingleJoinColumn($value)) { |
@@ -491,22 +491,22 @@ discard block |
||
491 | 491 | $association = $meta->getAssociationMapping($value); |
492 | 492 | $this->setLeftJoin( |
493 | 493 | $meta->getAssociationTargetClass($value), |
494 | - $association['joinColumns'][0]['referencedColumnName'], |
|
495 | - $association['fieldName'], |
|
494 | + $association[ 'joinColumns' ][ 0 ][ 'referencedColumnName' ], |
|
495 | + $association[ 'fieldName' ], |
|
496 | 496 | $alias, |
497 | 497 | $parentAlias |
498 | 498 | ); |
499 | 499 | } elseif ($meta->isCollectionValuedAssociation($value)) { |
500 | 500 | $association = $meta->getAssociationMapping($value); |
501 | - if (empty($association['mappedBy']) && empty($association['joinTable'])) { |
|
501 | + if (empty($association[ 'mappedBy' ]) && empty($association[ 'joinTable' ])) { |
|
502 | 502 | //não tem como fazer o join |
503 | 503 | $this->critical(sprintf('"%s" não é uma associação válida', $campo)); |
504 | 504 | continue; |
505 | 505 | } |
506 | - if (!empty($association['joinTable'])) { |
|
506 | + if (!empty($association[ 'joinTable' ])) { |
|
507 | 507 | //manyToMany |
508 | 508 | $this->setManyToManyJoin( |
509 | - $this->getFullFieldName($association['fieldName'], $parentAlias), |
|
509 | + $this->getFullFieldName($association[ 'fieldName' ], $parentAlias), |
|
510 | 510 | $alias, |
511 | 511 | $this->setManyToManyValuedCondition($association, $alias, $arr) |
512 | 512 | ); |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | //oneToMany |
515 | 515 | $this->setLeftJoin( |
516 | 516 | $meta->getAssociationTargetClass($value), |
517 | - $this->getTargetField($dados['meta'], $meta, $value), |
|
518 | - $meta->getIdentifierColumnNames()[0], |
|
517 | + $this->getTargetField($dados[ 'meta' ], $meta, $value), |
|
518 | + $meta->getIdentifierColumnNames()[ 0 ], |
|
519 | 519 | $alias, |
520 | 520 | $parentAlias |
521 | 521 | ); |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | //subClass |
525 | 525 | if (count($meta->subClasses) > 0) { |
526 | 526 | $temp = $this->getSubClassFields($meta, $value); |
527 | - if (!empty($temp['meta'])) { |
|
528 | - $this->setLeftJoin($temp['table'], $temp['targetField'], $temp['parentField'], $alias, $parentAlias); |
|
529 | - $tempMeta = $temp['meta']; |
|
527 | + if (!empty($temp[ 'meta' ])) { |
|
528 | + $this->setLeftJoin($temp[ 'table' ], $temp[ 'targetField' ], $temp[ 'parentField' ], $alias, $parentAlias); |
|
529 | + $tempMeta = $temp[ 'meta' ]; |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
@@ -553,23 +553,23 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return string |
555 | 555 | */ |
556 | - private function getMetaAndAliases() |
|
556 | + private function getMetaAndAliases () |
|
557 | 557 | { |
558 | 558 | $arr = explode('.', $this->field); |
559 | 559 | $meta = $this->getClassMetadata(); |
560 | - $metaAnterior = []; |
|
560 | + $metaAnterior = [ ]; |
|
561 | 561 | $parent = ''; |
562 | 562 | $alias = ''; |
563 | 563 | |
564 | 564 | for ($i = 0; $i <= $this->position; $i++) { |
565 | 565 | $metaAnterior = $meta; |
566 | 566 | |
567 | - if ($meta->hasAssociation($arr[$i])) { |
|
568 | - $class = $meta->getAssociationTargetClass($arr[$i]); |
|
567 | + if ($meta->hasAssociation($arr[ $i ])) { |
|
568 | + $class = $meta->getAssociationTargetClass($arr[ $i ]); |
|
569 | 569 | } elseif (count($meta->subClasses) > 0) { |
570 | - $temp = $this->getSubClassFields($meta, $arr[$i]); |
|
571 | - if (!empty($temp['meta'])) { |
|
572 | - $class = $temp['table']; |
|
570 | + $temp = $this->getSubClassFields($meta, $arr[ $i ]); |
|
571 | + if (!empty($temp[ 'meta' ])) { |
|
572 | + $class = $temp[ 'table' ]; |
|
573 | 573 | } |
574 | 574 | } |
575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
577 | 577 | |
578 | 578 | if ($i < $this->position) { |
579 | 579 | $parent .= $parent != '' ? '_' : ''; |
580 | - $parent .= $arr[$i]; |
|
580 | + $parent .= $arr[ $i ]; |
|
581 | 581 | } |
582 | 582 | if ($i == $this->position) { |
583 | 583 | $alias .= $parent; |
584 | 584 | $alias .= $parent != '' ? '_' : ''; |
585 | - $alias .= $arr[$i]; |
|
585 | + $alias .= $arr[ $i ]; |
|
586 | 586 | } |
587 | 587 | } |
588 | 588 | |
@@ -610,12 +610,12 @@ discard block |
||
610 | 610 | * @param string $alias |
611 | 611 | * @param string $parentAlias |
612 | 612 | */ |
613 | - private function setJoin($table, $field, $parentField, $alias, $parentAlias) |
|
613 | + private function setJoin ($table, $field, $parentField, $alias, $parentAlias) |
|
614 | 614 | { |
615 | 615 | if (!in_array($alias, $this->tables)) { |
616 | 616 | $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias); |
617 | 617 | $this->queryBuilder->join($table, $alias, 'WITH', $condition); |
618 | - $this->tables[] = $alias; |
|
618 | + $this->tables[ ] = $alias; |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @param string $parentAlias |
630 | 630 | * @param bool $withWhere |
631 | 631 | */ |
632 | - private function setLeftJoin($table, $field, $parentField, $alias, $parentAlias, $withWhere = false) |
|
632 | + private function setLeftJoin ($table, $field, $parentField, $alias, $parentAlias, $withWhere = false) |
|
633 | 633 | { |
634 | 634 | if (!in_array($alias, $this->tables)) { |
635 | 635 | $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | if ($withWhere) { |
638 | 638 | $this->queryBuilder->andWhere($condition); |
639 | 639 | } |
640 | - $this->tables[] = $alias; |
|
640 | + $this->tables[ ] = $alias; |
|
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
@@ -650,14 +650,14 @@ discard block |
||
650 | 650 | * |
651 | 651 | * @return mix|null |
652 | 652 | */ |
653 | - private function setManyToManyValuedCondition($association, $alias, $arr) |
|
653 | + private function setManyToManyValuedCondition ($association, $alias, $arr) |
|
654 | 654 | { |
655 | - if (empty($this->fieldValue['value']) || $this->position < count($arr) - 2) { |
|
655 | + if (empty($this->fieldValue[ 'value' ]) || $this->position < count($arr) - 2) { |
|
656 | 656 | return null; |
657 | 657 | } |
658 | - $targetField = $this->position == count($arr) - 1 ? $association['joinTable']['joinColumns'][0]['referencedColumnName'] : end($arr); |
|
658 | + $targetField = $this->position == count($arr) - 1 ? $association[ 'joinTable' ][ 'joinColumns' ][ 0 ][ 'referencedColumnName' ] : end($arr); |
|
659 | 659 | |
660 | - return $this->makeExpression($targetField, $this->fieldValue['operation'], $this->fieldValue['value'], $alias); |
|
660 | + return $this->makeExpression($targetField, $this->fieldValue[ 'operation' ], $this->fieldValue[ 'value' ], $alias); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @param string $alias |
668 | 668 | * @param mix $condition |
669 | 669 | */ |
670 | - private function setManyToManyJoin($table, $alias, $condition = null) |
|
670 | + private function setManyToManyJoin ($table, $alias, $condition = null) |
|
671 | 671 | { |
672 | 672 | if (!in_array($alias, $this->tables)) { |
673 | 673 | if ($condition) { |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | } else { |
676 | 676 | $this->queryBuilder->join($table, $alias); |
677 | 677 | } |
678 | - $this->tables[] = $alias; |
|
678 | + $this->tables[ ] = $alias; |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
@@ -686,19 +686,19 @@ discard block |
||
686 | 686 | * @param $value |
687 | 687 | * @param $alias |
688 | 688 | */ |
689 | - private function setQueryField($meta, $value, $alias) |
|
689 | + private function setQueryField ($meta, $value, $alias) |
|
690 | 690 | { |
691 | 691 | $campo = $this->getFullFieldName($value, $alias); |
692 | 692 | |
693 | 693 | if ($meta->isSingleValuedAssociation($value)) { |
694 | - $targetField = $meta->getAssociationMapping($value)['joinColumns'][0]['referencedColumnName']; |
|
694 | + $targetField = $meta->getAssociationMapping($value)[ 'joinColumns' ][ 0 ][ 'referencedColumnName' ]; |
|
695 | 695 | $alias = $alias == self::DEFAULT_TABLE_ALIAS ? substr($campo, strpos($campo, '.') + 1) : $alias.'_'.$targetField; |
696 | 696 | $campo = 'IDENTITY('.$campo.') '.$alias; |
697 | 697 | } elseif ($this->position > 0) { |
698 | 698 | $campo = '('.$campo.') AS '.$alias.'_'.$value; |
699 | 699 | } |
700 | 700 | // acrescenta o campo ao select |
701 | - $this->queryFields[] = $campo; |
|
701 | + $this->queryFields[ ] = $campo; |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - private function getSubClassFields($meta, $value) |
|
712 | + private function getSubClassFields ($meta, $value) |
|
713 | 713 | { |
714 | 714 | foreach ($meta->subClasses as $subClass) { |
715 | 715 | $delimiter = strpos($subClass, '/') > 0 ? '/' : '\\'; |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | if (end($temp) == $value) { |
719 | 719 | return [ |
720 | 720 | 'table' => $subClass, |
721 | - 'parentField' => $meta->getIdentifierColumnNames()[0], |
|
722 | - 'targetField' => $tempMeta->getIdentifierColumnNames()[0], |
|
721 | + 'parentField' => $meta->getIdentifierColumnNames()[ 0 ], |
|
722 | + 'targetField' => $tempMeta->getIdentifierColumnNames()[ 0 ], |
|
723 | 723 | 'meta' => $tempMeta, |
724 | 724 | ]; |
725 | 725 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * |
736 | 736 | * @return string |
737 | 737 | */ |
738 | - private function getTargetField($meta, $parentMeta, $value) |
|
738 | + private function getTargetField ($meta, $parentMeta, $value) |
|
739 | 739 | { |
740 | 740 | if (count($parentMeta->parentClasses) > 0) { |
741 | 741 | foreach ($parentMeta->parentClasses as $classe) { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | return $field; |
756 | 756 | } |
757 | 757 | |
758 | - return $meta->getIdentifierColumnNames()[0]; |
|
758 | + return $meta->getIdentifierColumnNames()[ 0 ]; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -767,11 +767,11 @@ discard block |
||
767 | 767 | * |
768 | 768 | * @return string |
769 | 769 | */ |
770 | - private function searchAssociationField($associationsByTargetClass, $parentTable, $value) |
|
770 | + private function searchAssociationField ($associationsByTargetClass, $parentTable, $value) |
|
771 | 771 | { |
772 | 772 | foreach ($associationsByTargetClass as $table => $association) { |
773 | - if ($table == $parentTable && $association['inversedBy'] == $value) { |
|
774 | - return $association['fieldName']; |
|
773 | + if ($table == $parentTable && $association[ 'inversedBy' ] == $value) { |
|
774 | + return $association[ 'fieldName' ]; |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | } |
@@ -781,14 +781,14 @@ discard block |
||
781 | 781 | * @param string $expression |
782 | 782 | * @param string $alias |
783 | 783 | */ |
784 | - private function getSelectExpression($expression, $field, $alias, $fieldAlias = self::DEFAULT_TABLE_ALIAS) |
|
784 | + private function getSelectExpression ($expression, $field, $alias, $fieldAlias = self::DEFAULT_TABLE_ALIAS) |
|
785 | 785 | { |
786 | - $validExpressions = ['SUM', 'MIN', 'MAX', 'AVG', 'COUNT']; |
|
786 | + $validExpressions = [ 'SUM', 'MIN', 'MAX', 'AVG', 'COUNT' ]; |
|
787 | 787 | if (in_array(trim(strtoupper($expression)), $validExpressions)) { |
788 | 788 | if (strpos($field, '.') === false) { |
789 | 789 | $field = getFullFieldName($field, $fieldAlias); |
790 | 790 | } |
791 | - $this->queryFields[] = sprintf('%s(%s) AS %s', $expression, $field, $alias); |
|
791 | + $this->queryFields[ ] = sprintf('%s(%s) AS %s', $expression, $field, $alias); |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | * |
799 | 799 | * @return string |
800 | 800 | */ |
801 | - protected function getFullFieldName($field, $alias = self::DEFAULT_TABLE_ALIAS, $separator = '.') |
|
801 | + protected function getFullFieldName ($field, $alias = self::DEFAULT_TABLE_ALIAS, $separator = '.') |
|
802 | 802 | { |
803 | 803 | return sprintf('%s%s%s', $alias, $separator, $field); |
804 | 804 | } |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @param null $value |
810 | 810 | * @param string $alias |
811 | 811 | */ |
812 | - protected function makeExpression($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
812 | + protected function makeExpression ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS) |
|
813 | 813 | { |
814 | 814 | $originalValue = $value; |
815 | 815 | |
@@ -871,10 +871,10 @@ discard block |
||
871 | 871 | $expression = $alias.' INSTANCE OF '.$value; |
872 | 872 | break; |
873 | 873 | case 'between': |
874 | - $expression = $this->queryBuilder->expr()->between($field, $this->queryBuilder->expr()->literal($value[0]), $this->queryBuilder->expr()->literal($value[1])); |
|
874 | + $expression = $this->queryBuilder->expr()->between($field, $this->queryBuilder->expr()->literal($value[ 0 ]), $this->queryBuilder->expr()->literal($value[ 1 ])); |
|
875 | 875 | break; |
876 | 876 | case 'dateparteq': |
877 | - $expression = $this->queryBuilder->expr()->eq("DATEPART('".$value['format']."', ".$field.')', $value['value']); |
|
877 | + $expression = $this->queryBuilder->expr()->eq("DATEPART('".$value[ 'format' ]."', ".$field.')', $value[ 'value' ]); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | return $expression; |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | /** |
884 | 884 | * @return string |
885 | 885 | */ |
886 | - protected function tableAlias() |
|
886 | + protected function tableAlias () |
|
887 | 887 | { |
888 | 888 | return self::DEFAULT_TABLE_ALIAS.count($this->queryBuilder->getAllAliases()); |
889 | 889 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param string $file |
9 | 9 | */ |
10 | - function register_annotation_file(string $file) |
|
10 | + function register_annotation_file (string $file) |
|
11 | 11 | { |
12 | 12 | if (!is_file($file)) { |
13 | 13 | return false; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param string $dir |
26 | 26 | */ |
27 | - function register_annotation_dir(string $dir) |
|
27 | + function register_annotation_dir (string $dir) |
|
28 | 28 | { |
29 | 29 | if (!is_dir($dir)) { |
30 | 30 | return false; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $handle = opendir($dir); |
34 | 34 | while ($path = readdir($handle)) { |
35 | - $toRegisterPath = implode(DIRECTORY_SEPARATOR, [$dir, $path]); |
|
35 | + $toRegisterPath = implode(DIRECTORY_SEPARATOR, [ $dir, $path ]); |
|
36 | 36 | register_annotation_file($toRegisterPath); |
37 | 37 | } |
38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * Retrieve all annotations of a giving object |
45 | 45 | */ |
46 | 46 | if (!function_exists('get_class_annotations')) { |
47 | - function get_class_annotations($element, $annotation = null) |
|
47 | + function get_class_annotations ($element, $annotation = null) |
|
48 | 48 | { |
49 | 49 | $class = $element; |
50 | 50 | if (is_object($element)) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Retrieve annotations of a especific property of a giving object |
63 | 63 | */ |
64 | 64 | if (!function_exists('get_property_annotations')) { |
65 | - function get_property_annotations($element, $property = null, $annotation = null) |
|
65 | + function get_property_annotations ($element, $property = null, $annotation = null) |
|
66 | 66 | { |
67 | 67 | $class = $element; |
68 | 68 | if (is_object($element) && !($element instanceof \ReflectionClass)) { |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | $reflectClass = new \ReflectionClass($class); |
82 | 82 | $reflectProperties = $reflectClass->getProperties(); |
83 | - $annotations = []; |
|
83 | + $annotations = [ ]; |
|
84 | 84 | foreach ($reflectProperties as $property) { |
85 | - $annotations[$property->getName()] = get_property_annotations($reflectClass, $property, $annotation); |
|
85 | + $annotations[ $property->getName() ] = get_property_annotations($reflectClass, $property, $annotation); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return $annotations; |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface QueryWorkerContract |
6 | 6 | { |
7 | - public function __construct(RepositoryContract $repository); |
|
7 | + public function __construct (RepositoryContract $repository); |
|
8 | 8 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param string $key |
9 | 9 | */ |
10 | - function env($key, $defaultValue = '') |
|
10 | + function env ($key, $defaultValue = '') |
|
11 | 11 | { |
12 | 12 | $env = getenv($key); |
13 | 13 | if (!$env) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param string $input |
24 | 24 | */ |
25 | - function onlyNumbers(string $input) |
|
25 | + function onlyNumbers (string $input) |
|
26 | 26 | { |
27 | 27 | return preg_replace('/\D/i', '', $input); |
28 | 28 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $from = 'Y-m-d' |
35 | 35 | * @param string $to = 'obj' |
36 | 36 | */ |
37 | - function parseDate($date, string $from = 'Y-m-d', string $to = 'obj') |
|
37 | + function parseDate ($date, string $from = 'Y-m-d', string $to = 'obj') |
|
38 | 38 | { |
39 | 39 | if ($date instanceof DateTime && $to === 'obj') { |
40 | 40 | return $date; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Dump and die. |
70 | 70 | */ |
71 | 71 | if (!function_exists('dd')) { |
72 | - function dd() |
|
72 | + function dd () |
|
73 | 73 | { |
74 | 74 | $args = func_get_args(); |
75 | 75 | foreach ($args as $arg) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Print and die |
84 | 84 | */ |
85 | 85 | if (!function_exists('pd')) { |
86 | - function pd() |
|
86 | + function pd () |
|
87 | 87 | { |
88 | 88 | $args = func_get_args(); |
89 | 89 | foreach ($args as $arg) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Dump and return |
98 | 98 | */ |
99 | 99 | if (!function_exists('dr')) { |
100 | - function dr() |
|
100 | + function dr () |
|
101 | 101 | { |
102 | 102 | $args = func_get_args(); |
103 | 103 | $result = ''; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function boot() |
|
14 | + public function boot () |
|
15 | 15 | { |
16 | 16 | // |
17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return void |
23 | 23 | */ |
24 | - public function register() |
|
24 | + public function register () |
|
25 | 25 | { |
26 | 26 | $arrClassName = [ |
27 | 27 | 'Rota', |
@@ -26,24 +26,24 @@ |
||
26 | 26 | */ |
27 | 27 | protected $alias; |
28 | 28 | |
29 | - public function getNome() |
|
29 | + public function getNome () |
|
30 | 30 | { |
31 | 31 | return $this->nome; |
32 | 32 | } |
33 | 33 | |
34 | - public function setNome($nome) |
|
34 | + public function setNome ($nome) |
|
35 | 35 | { |
36 | 36 | $this->nome = $nome; |
37 | 37 | |
38 | 38 | return $this; |
39 | 39 | } |
40 | 40 | |
41 | - public function getAlias() |
|
41 | + public function getAlias () |
|
42 | 42 | { |
43 | 43 | return $this->alias; |
44 | 44 | } |
45 | 45 | |
46 | - public function setAlias($alias) |
|
46 | + public function setAlias ($alias) |
|
47 | 47 | { |
48 | 48 | $this->alias = $alias; |
49 | 49 |
@@ -6,37 +6,37 @@ |
||
6 | 6 | |
7 | 7 | interface EntityContract |
8 | 8 | { |
9 | - public function getId(); |
|
9 | + public function getId (); |
|
10 | 10 | |
11 | - public function getCreatedAt(): DateTime; |
|
11 | + public function getCreatedAt (): DateTime; |
|
12 | 12 | |
13 | - public function getUpdatedAt(): DateTime; |
|
13 | + public function getUpdatedAt (): DateTime; |
|
14 | 14 | |
15 | - public function getDeletedAt(): DateTime; |
|
15 | + public function getDeletedAt (): DateTime; |
|
16 | 16 | |
17 | - public function getRepository(): RepositoryContract; |
|
17 | + public function getRepository (): RepositoryContract; |
|
18 | 18 | |
19 | - public function preRemove(); |
|
19 | + public function preRemove (); |
|
20 | 20 | |
21 | - public function postRemove(); |
|
21 | + public function postRemove (); |
|
22 | 22 | |
23 | - public function prePersist(); |
|
23 | + public function prePersist (); |
|
24 | 24 | |
25 | - public function postPersist(); |
|
25 | + public function postPersist (); |
|
26 | 26 | |
27 | - public function preUpdate(); |
|
27 | + public function preUpdate (); |
|
28 | 28 | |
29 | - public function postUpdate(); |
|
29 | + public function postUpdate (); |
|
30 | 30 | |
31 | - public function preFlush(); |
|
31 | + public function preFlush (); |
|
32 | 32 | |
33 | - public function persist(): EntityContract; |
|
33 | + public function persist (): EntityContract; |
|
34 | 34 | |
35 | - public function flush(): EntityContract; |
|
35 | + public function flush (): EntityContract; |
|
36 | 36 | |
37 | - public function remove(): EntityContract; |
|
37 | + public function remove (): EntityContract; |
|
38 | 38 | |
39 | - public function undelete(): EntityContract; |
|
39 | + public function undelete (): EntityContract; |
|
40 | 40 | |
41 | - public function toArray(array $options = []): array; |
|
41 | + public function toArray (array $options = [ ]): array; |
|
42 | 42 | } |
@@ -7,21 +7,21 @@ |
||
7 | 7 | |
8 | 8 | interface RepositoryContract |
9 | 9 | { |
10 | - public function getEntityManager(): EntityManager; |
|
10 | + public function getEntityManager (): EntityManager; |
|
11 | 11 | |
12 | - public function getClassMetadata(): ClassMetadata; |
|
12 | + public function getClassMetadata (): ClassMetadata; |
|
13 | 13 | |
14 | - public function createQueryWorker(): QueryWorkerContract; |
|
14 | + public function createQueryWorker (): QueryWorkerContract; |
|
15 | 15 | |
16 | - public function findAll(): QueryWorkerContract; |
|
16 | + public function findAll (): QueryWorkerContract; |
|
17 | 17 | |
18 | - public function findOneBy(array $criteria, bool $abort = true): EntityContract; |
|
18 | + public function findOneBy (array $criteria, bool $abort = true): EntityContract; |
|
19 | 19 | |
20 | - public function find($id, bool $abort = true): EntityContract; |
|
20 | + public function find ($id, bool $abort = true): EntityContract; |
|
21 | 21 | |
22 | - public function findAllRemoved(): QueryWorkerContract; |
|
22 | + public function findAllRemoved (): QueryWorkerContract; |
|
23 | 23 | |
24 | - public function findRemoved($id, bool $abort = true): EntityContract; |
|
24 | + public function findRemoved ($id, bool $abort = true): EntityContract; |
|
25 | 25 | |
26 | - public function createEntity(): EntityContract; |
|
26 | + public function createEntity (): EntityContract; |
|
27 | 27 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function disableSoftDeleteableFilter() |
|
3 | +function disableSoftDeleteableFilter () |
|
4 | 4 | { |
5 | 5 | if (\EntityManager::getFilters()->isEnabled('soft-deleteable')) { |
6 | 6 | \EntityManager::getFilters()->disable('soft-deleteable'); |
7 | 7 | } |
8 | 8 | } |
9 | -function enableSoftDeleteableFilter() |
|
9 | +function enableSoftDeleteableFilter () |
|
10 | 10 | { |
11 | 11 | if (!\EntityManager::getFilters()->isEnabled('soft-deleteable')) { |
12 | 12 | \EntityManager::getFilters()->enable('soft-deleteable'); |