Test Setup Failed
Pull Request — master (#41)
by Raí
06:28
created
Bludata/Doctrine/ORM/Repositories/QueryWorker.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@  discard block
 block discarded – undo
16 16
 
17 17
     protected $classMetadata;
18 18
 
19
-    protected $entitys        = [];
19
+    protected $entitys        = [ ];
20 20
 
21
-    protected $tables         = [];
21
+    protected $tables         = [ ];
22 22
 
23
-    protected $queryFields    = [];
23
+    protected $queryFields    = [ ];
24 24
 
25
-    protected $expressions    = [];
25
+    protected $expressions    = [ ];
26 26
 
27
-    protected $groupFields    = [];
27
+    protected $groupFields    = [ ];
28 28
 
29
-    protected $field          = [];
29
+    protected $field          = [ ];
30 30
 
31 31
     protected $position       = 0;
32 32
 
33
-    protected $fieldValue     = [];
33
+    protected $fieldValue     = [ ];
34 34
 
35
-    public function __construct(BdContracts\RepositoryContract $repository)
35
+    public function __construct (BdContracts\RepositoryContract $repository)
36 36
     {
37 37
         $this->em            = $repository->getEntityManager();
38 38
         $this->queryBuilder  = $repository->createQueryBuilder(self::DEFAULT_TABLE_ALIAS);
39 39
         $this->classMetadata = $repository->getClassMetadata();
40 40
     }
41 41
 
42
-    public function getResult(): ArrayCollection
42
+    public function getResult (): ArrayCollection
43 43
     {
44 44
         return new ArrayCollection($this->queryBuilder->getQuery()->execute());
45 45
     }
46 46
 
47
-    public function getOneResult(): ?BdContracts\EntityContract
47
+    public function getOneResult (): ?BdContracts\EntityContract
48 48
     {
49 49
         return $this->queryBuilder->getQuery()->getOneOrNullResult();
50 50
     }
51 51
 
52
-    public function toArray(array $options = []): array
52
+    public function toArray (array $options = [ ]): array
53 53
     {
54 54
         return $this->getResult()
55 55
                     ->map(function ($element) use ($options){
@@ -64,40 +64,40 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return QueryWorker
66 66
      */
67
-    public function withFilters(array $filters = null)
67
+    public function withFilters (array $filters = null)
68 68
     {
69 69
         if ($filters) {
70 70
             foreach ($filters as $filter) {
71
-                switch ($filter['type']) {
71
+                switch ($filter[ 'type' ]) {
72 72
                     case 'select':
73
-                        $this->select($filter['fields']);
73
+                        $this->select($filter[ 'fields' ]);
74 74
                         break;
75 75
                     case 'andWhere':
76
-                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
76
+                        $this->andWhere($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]);
77 77
                         break;
78 78
                     case 'orWhere':
79
-                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
79
+                        $this->orWhere($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]);
80 80
                         break;
81 81
                     case 'andHaving':
82
-                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
82
+                        $this->andHaving($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]);
83 83
                         break;
84 84
                     case 'orHaving':
85
-                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
85
+                        $this->orHaving($filter[ 'field' ], $filter[ 'operation' ], $filter[ 'value' ]);
86 86
                         break;
87 87
                     case 'addGroupBy':
88
-                        $this->addGroupBy($filter['field']);
88
+                        $this->addGroupBy($filter[ 'field' ]);
89 89
                         break;
90 90
                     case 'addOrderBy':
91
-                        $this->addOrderBy($filter['field'], $filter['order']);
91
+                        $this->addOrderBy($filter[ 'field' ], $filter[ 'order' ]);
92 92
                         break;
93 93
                     case 'fkAddOrderBy':
94
-                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
94
+                        $this->fkAddOrderBy($filter[ 'field' ], $filter[ 'fkField' ], $filter[ 'order' ]);
95 95
                         break;
96 96
                     case 'paginate':
97
-                        if (isset($filter['page'])) {
98
-                            $this->paginate($filter['limit'], $filter['page']);
97
+                        if (isset($filter[ 'page' ])) {
98
+                            $this->paginate($filter[ 'limit' ], $filter[ 'page' ]);
99 99
                         } else {
100
-                            $this->paginate($filter['limit']);
100
+                            $this->paginate($filter[ 'limit' ]);
101 101
                         }
102 102
                         break;
103 103
                 }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      *
116 116
      * @return $this
117 117
      */
118
-    public function paginate($limit = 25, $page = 0)
118
+    public function paginate ($limit = 25, $page = 0)
119 119
     {
120 120
         if ($limit > 0) {
121 121
             $this->queryBuilder->setMaxResults($limit);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      *
138 138
      * @return $this
139 139
      */
140
-    public function andWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
140
+    public function andWhere ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
141 141
     {
142 142
         if (strpos($field, '.') > 0) {
143 143
             //monta os joins
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
                 'operation' => $operation,
147 147
             ];
148 148
             $newAliasField = $this->associationQueryFields($field);
149
-            $alias = $newAliasField['alias'];
150
-            $field = $newAliasField['field'];
149
+            $alias = $newAliasField[ 'alias' ];
150
+            $field = $newAliasField[ 'field' ];
151 151
         }
152 152
         $this->queryBuilder->andWhere($this->makeExpression($field, $operation, $value, $alias));
153 153
 
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @return $this
165 165
      */
166
-    public function orWhere($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
166
+    public function orWhere ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
167 167
     {
168 168
         if (strpos($field, '.') > 0) {
169 169
             //monta os joins
170 170
             $newAliasField = $this->associationQueryFields($field);
171
-            $alias = $newAliasField['alias'];
172
-            $field = $newAliasField['field'];
171
+            $alias = $newAliasField[ 'alias' ];
172
+            $field = $newAliasField[ 'field' ];
173 173
         }
174 174
         $this->queryBuilder->orWhere($this->makeExpression($field, $operation, $value, $alias));
175 175
 
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return $this
185 185
      */
186
-    private function makeExpressions($conditions, $alias = self::DEFAULT_TABLE_ALIAS)
186
+    private function makeExpressions ($conditions, $alias = self::DEFAULT_TABLE_ALIAS)
187 187
     {
188
-        $expressions = [];
188
+        $expressions = [ ];
189 189
         foreach ($conditions as $attr) {
190
-            $field = $attr['field'];
190
+            $field = $attr[ 'field' ];
191 191
             if (strpos($field, '.') > 0) {
192 192
                 //monta os joins
193 193
                 $newAliasField = $this->associationQueryFields($field);
194
-                $alias = $newAliasField['alias'];
195
-                $field = $newAliasField['field'];
194
+                $alias = $newAliasField[ 'alias' ];
195
+                $field = $newAliasField[ 'field' ];
196 196
             }
197
-            $expressions[] = $this->makeExpression($field, $attr['operation'], $attr['value'], $alias);
197
+            $expressions[ ] = $this->makeExpression($field, $attr[ 'operation' ], $attr[ 'value' ], $alias);
198 198
         }
199 199
 
200 200
         return $expressions;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @param string $field
207 207
      */
208
-    public function addGroupBy($field)
208
+    public function addGroupBy ($field)
209 209
     {
210 210
         $alias = self::DEFAULT_TABLE_ALIAS;
211 211
         if (strpos($field, '.') > 0) {
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
         }
215 215
         if (count($this->queryFields) > 0) {
216 216
             foreach ($this->queryFields as $item) {
217
-                $parts = [];
217
+                $parts = [ ];
218 218
                 if (strpos($item, ' AS ')) {
219 219
                     $item = str_replace(')', '', str_replace('(', '', $item));
220 220
                     $parts = explode('AS', $item);
221
-                    $item = trim($parts[0]);
221
+                    $item = trim($parts[ 0 ]);
222 222
                 }
223 223
                 if (!in_array($item, $this->groupFields)) {
224 224
                     $this->queryBuilder->addGroupBy($item);
225
-                    $this->groupFields[] = $item;
225
+                    $this->groupFields[ ] = $item;
226 226
                 }
227 227
             }
228 228
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      *
240 240
      * @return $this
241 241
      */
242
-    public function andHaving($field, $operation, $value = null)
242
+    public function andHaving ($field, $operation, $value = null)
243 243
     {
244 244
         throw new \Exception('Not implemented');
245 245
     }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param string $field
251 251
      */
252
-    public function orHaving($field, $operation, $value = null)
252
+    public function orHaving ($field, $operation, $value = null)
253 253
     {
254 254
         throw new \Exception('Not implemented');
255 255
     }
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
      * @param string $field
261 261
      * @param string $order
262 262
      */
263
-    public function addOrderBy($field, $order = 'ASC')
263
+    public function addOrderBy ($field, $order = 'ASC')
264 264
     {
265 265
         $alias = self::DEFAULT_TABLE_ALIAS;
266 266
         if (strpos($field, '.') > 0) {
267 267
             //monta os joins
268 268
             $newAliasField = $this->associationQueryFields($field);
269
-            $alias = $newAliasField['alias'];
270
-            $field = $newAliasField['field'];
269
+            $alias = $newAliasField[ 'alias' ];
270
+            $field = $newAliasField[ 'field' ];
271 271
         }
272 272
         $this->queryBuilder->addOrderBy($this->getFullFieldName($field, $alias), $order);
273 273
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      * @param string $field
281 281
      * @param string $order
282 282
      */
283
-    public function fkAddOrderBy($field, $fkField, $order = 'ASC')
283
+    public function fkAddOrderBy ($field, $fkField, $order = 'ASC')
284 284
     {
285 285
         $alias = $this->tableAlias();
286 286
         $this->queryBuilder->join($this->getFullFieldName($field), $alias);
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      * @param associationField.fkField
296 296
      * @param $field
297 297
      */
298
-    public function select($fields)
298
+    public function select ($fields)
299 299
     {
300 300
         foreach ($fields as $key => $value) {
301 301
             if (is_int($key)) {
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
                 $alias = $this->tableAlias();
305 305
                 $this->queryBuilder->join($this->getFullFieldName($key, self::DEFAULT_TABLE_ALIAS), $alias);
306 306
                 foreach ($value as $valueField) {
307
-                    $this->queryFields[] = $this->getFullFieldName($valueField, $alias);
307
+                    $this->queryFields[ ] = $this->getFullFieldName($valueField, $alias);
308 308
                 }
309 309
             } else {
310
-                $this->queryFields[] = $value;
310
+                $this->queryFields[ ] = $value;
311 311
             }
312 312
         }
313 313
         $this->queryBuilder->select(implode(',', $this->queryFields));
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      * @param associationField.fkField
322 322
      * @param $field
323 323
      */
324
-    public function associationQueryFields($campo)
324
+    public function associationQueryFields ($campo)
325 325
     {
326 326
         $this->field = $campo;
327 327
         $pos = strpos($campo, '.');
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
             $arr = explode('.', $campo);
330 330
             $lastField = end($arr);
331 331
 
332
-            if (count($arr) == 2 && $arr[0] == self::DEFAULT_TABLE_ALIAS) {
332
+            if (count($arr) == 2 && $arr[ 0 ] == self::DEFAULT_TABLE_ALIAS) {
333 333
                 //não é um campo composto
334 334
                 return [
335 335
                     'field' => $lastField,
336
-                    'alias' => $arr[0],
336
+                    'alias' => $arr[ 0 ],
337 337
                 ];
338 338
             }
339 339
 
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
                 if ($this->position < count($arr) - 1) {
345 345
                     $dados = $this->getMetaAndAliases();
346 346
 
347
-                    $alias = $dados['alias'];
348
-                    $parentAlias = $dados['parentAlias'];
347
+                    $alias = $dados[ 'alias' ];
348
+                    $parentAlias = $dados[ 'parentAlias' ];
349 349
 
350 350
                     if ($tempMeta) {
351 351
                         $meta = $tempMeta;
352 352
                         $tempMeta = '';
353 353
                     } else {
354
-                        $meta = $dados['parentMeta'];
354
+                        $meta = $dados[ 'parentMeta' ];
355 355
                     }
356 356
 
357 357
                     if ($meta->isAssociationWithSingleJoinColumn($value)) {
@@ -359,22 +359,22 @@  discard block
 block discarded – undo
359 359
                         $association = $meta->getAssociationMapping($value);
360 360
                         $this->setLeftJoin(
361 361
                             $meta->getAssociationTargetClass($value),
362
-                            $association['joinColumns'][0]['referencedColumnName'],
363
-                            $association['fieldName'],
362
+                            $association[ 'joinColumns' ][ 0 ][ 'referencedColumnName' ],
363
+                            $association[ 'fieldName' ],
364 364
                             $alias,
365 365
                             $parentAlias
366 366
                         );
367 367
                     } elseif ($meta->isCollectionValuedAssociation($value)) {
368 368
                         $association = $meta->getAssociationMapping($value);
369
-                        if (empty($association['mappedBy']) && empty($association['joinTable'])) {
369
+                        if (empty($association[ 'mappedBy' ]) && empty($association[ 'joinTable' ])) {
370 370
                             //não tem como fazer o join
371 371
                             $this->critical(sprintf('"%s" não é uma associação válida', $campo));
372 372
                             continue;
373 373
                         }
374
-                        if (!empty($association['joinTable'])) {
374
+                        if (!empty($association[ 'joinTable' ])) {
375 375
                             //manyToMany
376 376
                             $this->setManyToManyJoin(
377
-                                $this->getFullFieldName($association['fieldName'], $parentAlias),
377
+                                $this->getFullFieldName($association[ 'fieldName' ], $parentAlias),
378 378
                                 $alias,
379 379
                                 $this->setManyToManyValuedCondition($association, $alias, $arr)
380 380
                             );
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
                             //oneToMany
383 383
                             $this->setLeftJoin(
384 384
                                 $meta->getAssociationTargetClass($value),
385
-                                $this->getTargetField($dados['meta'], $meta, $value),
386
-                                $meta->getIdentifierColumnNames()[0],
385
+                                $this->getTargetField($dados[ 'meta' ], $meta, $value),
386
+                                $meta->getIdentifierColumnNames()[ 0 ],
387 387
                                 $alias,
388 388
                                 $parentAlias
389 389
                             );
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
                         //subClass
393 393
                         if (count($meta->subClasses) > 0) {
394 394
                             $temp = $this->getSubClassFields($meta, $value);
395
-                            if (!empty($temp['meta'])) {
396
-                                $this->setLeftJoin($temp['table'], $temp['targetField'], $temp['parentField'], $alias, $parentAlias);
397
-                                $tempMeta = $temp['meta'];
395
+                            if (!empty($temp[ 'meta' ])) {
396
+                                $this->setLeftJoin($temp[ 'table' ], $temp[ 'targetField' ], $temp[ 'parentField' ], $alias, $parentAlias);
397
+                                $tempMeta = $temp[ 'meta' ];
398 398
                             }
399 399
                         }
400 400
                     }
@@ -421,23 +421,23 @@  discard block
 block discarded – undo
421 421
      *
422 422
      * @return string
423 423
      */
424
-    private function getMetaAndAliases()
424
+    private function getMetaAndAliases ()
425 425
     {
426 426
         $arr = explode('.', $this->field);
427 427
         $meta = $this->classMetadata;
428
-        $metaAnterior = [];
428
+        $metaAnterior = [ ];
429 429
         $parent = '';
430 430
         $alias = '';
431 431
 
432 432
         for ($i = 0; $i <= $this->position; $i++) {
433 433
             $metaAnterior = $meta;
434 434
 
435
-            if ($meta->hasAssociation($arr[$i])) {
436
-                $class = $meta->getAssociationTargetClass($arr[$i]);
435
+            if ($meta->hasAssociation($arr[ $i ])) {
436
+                $class = $meta->getAssociationTargetClass($arr[ $i ]);
437 437
             } elseif (count($meta->subClasses) > 0) {
438
-                $temp = $this->getSubClassFields($meta, $arr[$i]);
439
-                if (!empty($temp['meta'])) {
440
-                    $class = $temp['table'];
438
+                $temp = $this->getSubClassFields($meta, $arr[ $i ]);
439
+                if (!empty($temp[ 'meta' ])) {
440
+                    $class = $temp[ 'table' ];
441 441
                 }
442 442
             }
443 443
 
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 
446 446
             if ($i < $this->position) {
447 447
                 $parent .= $parent != '' ? '_' : '';
448
-                $parent .= $arr[$i];
448
+                $parent .= $arr[ $i ];
449 449
             }
450 450
             if ($i == $this->position) {
451 451
                 $alias .= $parent;
452 452
                 $alias .= $parent != '' ? '_' : '';
453
-                $alias .= $arr[$i];
453
+                $alias .= $arr[ $i ];
454 454
             }
455 455
         }
456 456
 
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
      * @param string $alias
479 479
      * @param string $parentAlias
480 480
      */
481
-    private function setJoin($table, $field, $parentField, $alias, $parentAlias)
481
+    private function setJoin ($table, $field, $parentField, $alias, $parentAlias)
482 482
     {
483 483
         if (!in_array($alias, $this->tables)) {
484 484
             $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias);
485 485
             $this->queryBuilder->join($table, $alias, 'WITH', $condition);
486
-            $this->tables[] = $alias;
486
+            $this->tables[ ] = $alias;
487 487
         }
488 488
     }
489 489
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
      * @param string $parentAlias
498 498
      * @param bool   $withWhere
499 499
      */
500
-    private function setLeftJoin($table, $field, $parentField, $alias, $parentAlias, $withWhere = false)
500
+    private function setLeftJoin ($table, $field, $parentField, $alias, $parentAlias, $withWhere = false)
501 501
     {
502 502
         if (!in_array($alias, $this->tables)) {
503 503
             $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
             if ($withWhere) {
506 506
                 $this->queryBuilder->andWhere($condition);
507 507
             }
508
-            $this->tables[] = $alias;
508
+            $this->tables[ ] = $alias;
509 509
         }
510 510
     }
511 511
 
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
      *
519 519
      * @return mix|null
520 520
      */
521
-    private function setManyToManyValuedCondition($association, $alias, $arr)
521
+    private function setManyToManyValuedCondition ($association, $alias, $arr)
522 522
     {
523
-        if (empty($this->fieldValue['value']) || $this->position < count($arr) - 2) {
523
+        if (empty($this->fieldValue[ 'value' ]) || $this->position < count($arr) - 2) {
524 524
             return null;
525 525
         }
526
-        $targetField = $this->position == count($arr) - 1 ? $association['joinTable']['joinColumns'][0]['referencedColumnName'] : end($arr);
526
+        $targetField = $this->position == count($arr) - 1 ? $association[ 'joinTable' ][ 'joinColumns' ][ 0 ][ 'referencedColumnName' ] : end($arr);
527 527
 
528
-        return $this->makeExpression($targetField, $this->fieldValue['operation'], $this->fieldValue['value'], $alias);
528
+        return $this->makeExpression($targetField, $this->fieldValue[ 'operation' ], $this->fieldValue[ 'value' ], $alias);
529 529
     }
530 530
 
531 531
     /**
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
      * @param string $alias
536 536
      * @param mix    $condition
537 537
      */
538
-    private function setManyToManyJoin($table, $alias, $condition = null)
538
+    private function setManyToManyJoin ($table, $alias, $condition = null)
539 539
     {
540 540
         if (!in_array($alias, $this->tables)) {
541 541
             if ($condition) {
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
             } else {
544 544
                 $this->queryBuilder->join($table, $alias);
545 545
             }
546
-            $this->tables[] = $alias;
546
+            $this->tables[ ] = $alias;
547 547
         }
548 548
     }
549 549
 
@@ -554,19 +554,19 @@  discard block
 block discarded – undo
554 554
      * @param $value
555 555
      * @param $alias
556 556
      */
557
-    private function setQueryField($meta, $value, $alias)
557
+    private function setQueryField ($meta, $value, $alias)
558 558
     {
559 559
         $campo = $this->getFullFieldName($value, $alias);
560 560
 
561 561
         if ($meta->isSingleValuedAssociation($value)) {
562
-            $targetField = $meta->getAssociationMapping($value)['joinColumns'][0]['referencedColumnName'];
562
+            $targetField = $meta->getAssociationMapping($value)[ 'joinColumns' ][ 0 ][ 'referencedColumnName' ];
563 563
             $alias = $alias == self::DEFAULT_TABLE_ALIAS ? substr($campo, strpos($campo, '.') + 1) : $alias.'_'.$targetField;
564 564
             $campo = 'IDENTITY('.$campo.') '.$alias;
565 565
         } elseif ($this->position > 0) {
566 566
             $campo = '('.$campo.') AS '.$alias.'_'.$value;
567 567
         }
568 568
         // acrescenta o campo ao select
569
-        $this->queryFields[] = $campo;
569
+        $this->queryFields[ ] = $campo;
570 570
     }
571 571
 
572 572
     /**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
      *
578 578
      * @return string
579 579
      */
580
-    private function getSubClassFields($meta, $value)
580
+    private function getSubClassFields ($meta, $value)
581 581
     {
582 582
         foreach ($meta->subClasses as $subClass) {
583 583
             $delimiter = strpos($subClass, '/') > 0 ? '/' : '\\';
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
             if (end($temp) == $value) {
587 587
                 return [
588 588
                     'table'       => $subClass,
589
-                    'parentField' => $meta->getIdentifierColumnNames()[0],
590
-                    'targetField' => $tempMeta->getIdentifierColumnNames()[0],
589
+                    'parentField' => $meta->getIdentifierColumnNames()[ 0 ],
590
+                    'targetField' => $tempMeta->getIdentifierColumnNames()[ 0 ],
591 591
                     'meta'        => $tempMeta,
592 592
                 ];
593 593
             }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      *
604 604
      * @return string
605 605
      */
606
-    private function getTargetField($meta, $parentMeta, $value)
606
+    private function getTargetField ($meta, $parentMeta, $value)
607 607
     {
608 608
         if (count($parentMeta->parentClasses) > 0) {
609 609
             foreach ($parentMeta->parentClasses as $classe) {
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
             return $field;
624 624
         }
625 625
 
626
-        return $meta->getIdentifierColumnNames()[0];
626
+        return $meta->getIdentifierColumnNames()[ 0 ];
627 627
     }
628 628
 
629 629
     /**
@@ -635,11 +635,11 @@  discard block
 block discarded – undo
635 635
      *
636 636
      * @return string
637 637
      */
638
-    private function searchAssociationField($associationsByTargetClass, $parentTable, $value)
638
+    private function searchAssociationField ($associationsByTargetClass, $parentTable, $value)
639 639
     {
640 640
         foreach ($associationsByTargetClass as $table => $association) {
641
-            if ($table == $parentTable && $association['inversedBy'] == $value) {
642
-                return $association['fieldName'];
641
+            if ($table == $parentTable && $association[ 'inversedBy' ] == $value) {
642
+                return $association[ 'fieldName' ];
643 643
             }
644 644
         }
645 645
     }
@@ -649,14 +649,14 @@  discard block
 block discarded – undo
649 649
      * @param string $expression
650 650
      * @param string $alias
651 651
      */
652
-    private function getSelectExpression($expression, $field, $alias, $fieldAlias = self::DEFAULT_TABLE_ALIAS)
652
+    private function getSelectExpression ($expression, $field, $alias, $fieldAlias = self::DEFAULT_TABLE_ALIAS)
653 653
     {
654
-        $validExpressions = ['SUM', 'MIN', 'MAX', 'AVG', 'COUNT'];
654
+        $validExpressions = [ 'SUM', 'MIN', 'MAX', 'AVG', 'COUNT' ];
655 655
         if (in_array(trim(strtoupper($expression)), $validExpressions)) {
656 656
             if (strpos($field, '.') === false) {
657 657
                 $field = getFullFieldName($field, $fieldAlias);
658 658
             }
659
-            $this->queryFields[] = sprintf('%s(%s) AS %s', $expression, $field, $alias);
659
+            $this->queryFields[ ] = sprintf('%s(%s) AS %s', $expression, $field, $alias);
660 660
         }
661 661
     }
662 662
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
      *
667 667
      * @return string
668 668
      */
669
-    protected function getFullFieldName($field, $alias = self::DEFAULT_TABLE_ALIAS, $separator = '.')
669
+    protected function getFullFieldName ($field, $alias = self::DEFAULT_TABLE_ALIAS, $separator = '.')
670 670
     {
671 671
         return sprintf('%s%s%s', $alias, $separator, $field);
672 672
     }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      * @param null   $value
678 678
      * @param string $alias
679 679
      */
680
-    protected function makeExpression($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
680
+    protected function makeExpression ($field, $operation, $value = null, $alias = self::DEFAULT_TABLE_ALIAS)
681 681
     {
682 682
         $originalValue = $value;
683 683
 
@@ -739,10 +739,10 @@  discard block
 block discarded – undo
739 739
                 $expression = $alias.' INSTANCE OF '.$value;
740 740
                 break;
741 741
             case 'between':
742
-                $expression = $this->queryBuilder->expr()->between($field, $this->queryBuilder->expr()->literal($value[0]), $this->queryBuilder->expr()->literal($value[1]));
742
+                $expression = $this->queryBuilder->expr()->between($field, $this->queryBuilder->expr()->literal($value[ 0 ]), $this->queryBuilder->expr()->literal($value[ 1 ]));
743 743
                 break;
744 744
             case 'dateparteq':
745
-                $expression = $this->queryBuilder->expr()->eq("DATEPART('".$value['format']."', ".$field.')', $value['value']);
745
+                $expression = $this->queryBuilder->expr()->eq("DATEPART('".$value[ 'format' ]."', ".$field.')', $value[ 'value' ]);
746 746
         }
747 747
 
748 748
         return $expression;
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
     /**
752 752
      * @return string
753 753
      */
754
-    protected function tableAlias()
754
+    protected function tableAlias ()
755 755
     {
756 756
         return self::DEFAULT_TABLE_ALIAS.count($this->queryBuilder->getAllAliases());
757 757
     }
Please login to merge, or discard this patch.
Bludata/Doctrine/ORM/Repositories/BaseRepository.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@  discard block
 block discarded – undo
11 11
 
12 12
 abstract class BaseRepository extends EntityRepository implements RepositoryContract
13 13
 {
14
-    public function getEntityManager(): EntityManager
14
+    public function getEntityManager (): EntityManager
15 15
     {
16 16
         return parent::getEntityManager();
17 17
     }
18 18
 
19
-    public function getClassMetadata(): ClassMetadata
19
+    public function getClassMetadata (): ClassMetadata
20 20
     {
21 21
         return parent::getClassMetadata();
22 22
     }
23 23
 
24
-    public function createQueryWorker(): QueryWorkerContract
24
+    public function createQueryWorker (): QueryWorkerContract
25 25
     {
26 26
         return new QueryWorker($this);
27 27
     }
28 28
 
29
-    public function findAll(): QueryWorkerContract
29
+    public function findAll (): QueryWorkerContract
30 30
     {
31 31
         return $this->createQueryWorker();
32 32
     }
33 33
 
34
-    public function findOneBy(array $criteria, bool $abort = true): ?EntityContract
34
+    public function findOneBy (array $criteria, bool $abort = true): ?EntityContract
35 35
     {
36 36
         $findAll = $this->findAll();
37 37
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
         return null;
53 53
     }
54 54
 
55
-    public function find($id, bool $abort = true): ?EntityContract
55
+    public function find ($id, bool $abort = true): ?EntityContract
56 56
     {
57
-        return $this->findOneBy(['id' => $id], $abort);
57
+        return $this->findOneBy([ 'id' => $id ], $abort);
58 58
     }
59 59
 
60
-    public function findAllRemoved(): QueryWorkerContract
60
+    public function findAllRemoved (): QueryWorkerContract
61 61
     {
62 62
         disableSoftDeleteableFilter();
63 63
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                     ->andWhere('deletedAt', 'isnotnull');
66 66
     }
67 67
 
68
-    public function findRemoved($id, bool $abort = true): ?EntityContract
68
+    public function findRemoved ($id, bool $abort = true): ?EntityContract
69 69
     {
70 70
         $entity = $this->findAllRemoved()
71 71
                        ->andWhere('id', '=', $id)
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
         abort(404, 'Registro não encontrado');
81 81
     }
82 82
 
83
-    public function createEntity(): EntityContract
83
+    public function createEntity (): EntityContract
84 84
     {
85 85
         $entityName = $this->getEntityName();
86 86
 
87 87
         return new $entityName();
88 88
     }
89 89
 
90
-    public function remove(EntityContract $entity): EntityContract
90
+    public function remove (EntityContract $entity): EntityContract
91 91
     {
92 92
         $this->getEntityManager()
93 93
              ->remove($entity);
Please login to merge, or discard this patch.
Bludata/Doctrine/ORM/Providers/ORMServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 class ORMServiceProvider extends ServiceProvider
8 8
 {
9
-    public function register()
9
+    public function register ()
10 10
     {
11 11
         $this->app->register(\Bludata\Doctrine\Common\Providers\CommonServiceProvider::class);
12 12
         $this->app->register(\LaravelDoctrine\Extensions\GedmoExtensionsServiceProvider::class);
Please login to merge, or discard this patch.
Bludata/Doctrine/ORM/Traits/ToArrayTrait.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,24 +11,24 @@  discard block
 block discarded – undo
11 11
 
12 12
 trait ToArrayTrait
13 13
 {
14
-    private function isOnly(ReflectionProperty $property, array $optionsToArray): bool
14
+    private function isOnly (ReflectionProperty $property, array $optionsToArray): bool
15 15
     {
16
-        if (!isset($optionsToArray['only']) && !isset($optionsToArray['except'])) {
16
+        if (!isset($optionsToArray[ 'only' ]) && !isset($optionsToArray[ 'except' ])) {
17 17
             return true;
18 18
         }
19 19
 
20
-        if (isset($optionsToArray['only'])) {
21
-            if (in_array($property->getName(), $optionsToArray['only'])) {
20
+        if (isset($optionsToArray[ 'only' ])) {
21
+            if (in_array($property->getName(), $optionsToArray[ 'only' ])) {
22 22
                 return true;
23 23
             }
24
-        } else if (isset($optionsToArray['except']) && !in_array($property->getName(), $optionsToArray['except'])) {
24
+        } else if (isset($optionsToArray[ 'except' ]) && !in_array($property->getName(), $optionsToArray[ 'except' ])) {
25 25
             return true;
26 26
         }
27 27
 
28 28
         return false;
29 29
     }
30 30
 
31
-    private function getPropertiesFillable(): array
31
+    private function getPropertiesFillable (): array
32 32
     {
33 33
         $allProperties = $this->getRepository()
34 34
                               ->getClassMetadata()
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
         });
45 45
     }
46 46
 
47
-    public function toArray(array $options = []): array
47
+    public function toArray (array $options = [ ]): array
48 48
     {
49 49
         $classMetadata = $this->getRepository()
50 50
                               ->getClassMetadata();
51 51
 
52 52
         $propertiesFillable = $this->getPropertiesFillable();
53 53
 
54
-        $array         = [];
54
+        $array = [ ];
55 55
 
56 56
         foreach ($propertiesFillable as $property) {
57 57
             if ($this->isOnly($property, $options)) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                             $dateFormat = 'Y-m-d';
65 65
 
66 66
                             if ($metaDataKey) {
67
-                                switch ($metaDataKey['type']) {
67
+                                switch ($metaDataKey[ 'type' ]) {
68 68
                                     case 'datetime':
69 69
                                         $dateFormat = 'Y-m-d H:i:s';
70 70
                                         break;
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
                                 }
77 77
                             }
78 78
 
79
-                            $array[$key] = $this->$key->format($dateFormat);
79
+                            $array[ $key ] = $this->$key->format($dateFormat);
80 80
                         }
81 81
                     } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) {
82
-                        $array[$key] = array_map(function ($item) {
82
+                        $array[ $key ] = array_map(function ($item) {
83 83
                             return $item->getId();
84 84
                         }, $this->$key->getValues());
85 85
                     } else {
86 86
                         if (method_exists($this->$key, 'getId')) {
87
-                            $array[$key] = $this->$key->getId();
87
+                            $array[ $key ] = $this->$key->getId();
88 88
                         } else {
89
-                            $array[$key] = $this->$key;
89
+                            $array[ $key ] = $this->$key;
90 90
                         }
91 91
                     }
92 92
                 } else {
93
-                    if (in_array($metaDataKey['type'], ['decimal', 'float'])) {
94
-                        $array[$key] = (float) $this->$key;
93
+                    if (in_array($metaDataKey[ 'type' ], [ 'decimal', 'float' ])) {
94
+                        $array[ $key ] = (float) $this->$key;
95 95
                     } else {
96
-                        $array[$key] = $this->$key;
96
+                        $array[ $key ] = $this->$key;
97 97
                     }
98 98
                 }
99 99
             }
Please login to merge, or discard this patch.
Bludata/Doctrine/ORM/Entities/BaseEntity.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,27 +48,27 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected $deletedAt;
50 50
 
51
-    public function getId()
51
+    public function getId ()
52 52
     {
53 53
         return $this->id;
54 54
     }
55 55
 
56
-    public function getCreatedAt(): ?DateTime
56
+    public function getCreatedAt (): ?DateTime
57 57
     {
58 58
         return $this->createdAt;
59 59
     }
60 60
 
61
-    public function getUpdatedAt(): ?DateTime
61
+    public function getUpdatedAt (): ?DateTime
62 62
     {
63 63
         return $this->createdAt;
64 64
     }
65 65
 
66
-    public function getDeletedAt(): ?DateTime
66
+    public function getDeletedAt (): ?DateTime
67 67
     {
68 68
         return $this->deletedAt;
69 69
     }
70 70
 
71
-    public function getRepository(): RepositoryContract
71
+    public function getRepository (): RepositoryContract
72 72
     {
73 73
         return EntityManager::getRepository(get_class($this));
74 74
     }
@@ -76,53 +76,53 @@  discard block
 block discarded – undo
76 76
     /**
77 77
      * @ORM\PreRemove
78 78
      */
79
-    public function preRemove()
79
+    public function preRemove ()
80 80
     {
81 81
     }
82 82
 
83 83
     /**
84 84
      * @ORM\PostRemove
85 85
      */
86
-    public function postRemove()
86
+    public function postRemove ()
87 87
     {
88 88
     }
89 89
 
90 90
     /**
91 91
      * @ORM\PrePersist
92 92
      */
93
-    public function prePersist()
93
+    public function prePersist ()
94 94
     {
95 95
     }
96 96
 
97 97
     /**
98 98
      * @ORM\PostPersist
99 99
      */
100
-    public function postPersist()
100
+    public function postPersist ()
101 101
     {
102 102
     }
103 103
 
104 104
     /**
105 105
      * @ORM\PreUpdate
106 106
      */
107
-    public function preUpdate()
107
+    public function preUpdate ()
108 108
     {
109 109
     }
110 110
 
111 111
     /**
112 112
      * @ORM\PostUpdate
113 113
      */
114
-    public function postUpdate()
114
+    public function postUpdate ()
115 115
     {
116 116
     }
117 117
 
118 118
     /**
119 119
      * @ORM\PreFlush
120 120
      */
121
-    public function preFlush()
121
+    public function preFlush ()
122 122
     {
123 123
     }
124 124
 
125
-    public function persist(): BdContracts\EntityContract
125
+    public function persist (): BdContracts\EntityContract
126 126
     {
127 127
         $this->getRepository()
128 128
              ->getEntityManager()
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         return $this;
132 132
     }
133 133
 
134
-    public function flush(): BdContracts\EntityContract
134
+    public function flush (): BdContracts\EntityContract
135 135
     {
136 136
         $this->getRepository()
137 137
              ->getEntityManager()
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         return $this;
141 141
     }
142 142
 
143
-    public function remove(): BdContracts\EntityContract
143
+    public function remove (): BdContracts\EntityContract
144 144
     {
145 145
         $this->getRepository()
146 146
              ->remove($this);
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         return $this;
149 149
     }
150 150
 
151
-    public function undelete(): BdContracts\EntityContract
151
+    public function undelete (): BdContracts\EntityContract
152 152
     {
153 153
         $this->deletedAt = null;
154 154
 
Please login to merge, or discard this patch.
resources/lang/pt-BR/validation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-return [];
3
+return [ ];
Please login to merge, or discard this patch.
database/migrations/Version20171016204335.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     /**
11 11
      * @param Schema $schema
12 12
      */
13
-    public function up(Schema $schema)
13
+    public function up (Schema $schema)
14 14
     {
15 15
         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
16 16
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * @param Schema $schema
22 22
      */
23
-    public function down(Schema $schema)
23
+    public function down (Schema $schema)
24 24
     {
25 25
         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
26 26
 
Please login to merge, or discard this patch.