Completed
Push — master ( d03ce1...a8196e )
by Raí
12s
created
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
-        } elseif (isset($optionsToArray['except']) && !in_array($property->getName(), $optionsToArray['except'])) {
24
+        } elseif (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.
Bludata/Doctrine/ORM/Repositories/BaseRepository.php 2 patches
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.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
             abort(404, 'Registro não encontrado');
50 50
         }
51 51
 
52
-        return null;
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 57
         return $this->findOneBy(['id' => $id], $abort);
58 58
     }
@@ -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)
Please login to merge, or discard this patch.