Completed
Pull Request — master (#35)
by Raí
12:03 queued 07:27
created
Bludata/Doctrine/ORM/Traits/ToArrayTrait.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 trait ToArrayTrait
6 6
 {
7
-    public function toArray(array $options = []): array
7
+    public function toArray (array $options = [ ]): array
8 8
     {
9 9
         $reflectionProperty = new ReflectionProperty(get_called_class(), $key);
10 10
         $annotationReader = new AnnotationReader();
11 11
         $propertyAnnotations = $annotationReader->getPropertyAnnotations($reflectionProperty);
12 12
 
13
-        $array = [];
13
+        $array = [ ];
14 14
 
15 15
         $classMetadata = $this->getRepository()
16 16
                               ->getClassMetadata();
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
                             $dateFormat = 'Y-m-d';
26 26
 
27 27
                             if ($metaDataKey) {
28
-                                switch ($metaDataKey['type']) {
28
+                                switch ($metaDataKey[ 'type' ]) {
29 29
                                     case 'datetime':
30 30
                                         $dateFormat = 'Y-m-d H:i:s';
31 31
                                         break;
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
                                 }
38 38
                             }
39 39
 
40
-                            $array[$key] = $this->$key->format($dateFormat);
40
+                            $array[ $key ] = $this->$key->format($dateFormat);
41 41
                         }
42 42
                     } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) {
43
-                        $ids = [];
43
+                        $ids = [ ];
44 44
 
45 45
                         foreach ($this->$key->getValues() as $item) {
46
-                            $ids[] = $item->getId();
46
+                            $ids[ ] = $item->getId();
47 47
                         }
48 48
 
49
-                        $array[$key] = $ids;
49
+                        $array[ $key ] = $ids;
50 50
                     } else {
51 51
                         if (method_exists($this->$key, 'getId')) {
52
-                            $array[$key] = $this->$key->getId();
52
+                            $array[ $key ] = $this->$key->getId();
53 53
                         } else {
54
-                            $array[$key] = $this->$key;
54
+                            $array[ $key ] = $this->$key;
55 55
                         }
56 56
                     }
57 57
                 } else {
58
-                    if ($metaDataKey['type'] == 'decimal') {
59
-                        $array[$key] = (float) $this->$key;
58
+                    if ($metaDataKey[ 'type' ] == 'decimal') {
59
+                        $array[ $key ] = (float) $this->$key;
60 60
                     } else {
61
-                        $array[$key] = $this->$key;
61
+                        $array[ $key ] = $this->$key;
62 62
                     }
63 63
                 }
64 64
             }
Please login to merge, or discard this patch.