Passed
Push — master ( 941273...52f3c0 )
by Fran
08:30
created
src/base/dto/Dto.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public function __construct($hydrate = true)
18 18
     {
19 19
         parent::__construct();
20
-        if($hydrate) {
20
+        if ($hydrate) {
21 21
             $this->fromArray(Request::getInstance()->getData());
22 22
         }
23 23
     }
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
                 /** @var \ReflectionProperty $property */
46 46
                 foreach ($properties as $property) {
47 47
                     $value = $property->getValue($this);
48
-                    if(is_object($value) && method_exists($value, 'toArray')) {
48
+                    if (is_object($value) && method_exists($value, 'toArray')) {
49 49
                         $dto[$property->getName()] = $value->toArray();
50
-                    } else {
50
+                    }else {
51 51
                         $dto[$property->getName()] = $property->getValue($this);
52 52
                     }
53 53
                 }
54 54
             }
55
-        } catch (\Exception $e) {
56
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
55
+        }catch (\Exception $e) {
56
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
57 57
         }
58 58
         return $dto;
59 59
     }
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
     protected function parseDtoField(array $properties, $key, $value = null) {
76 76
         $type = 'string';
77 77
         $is_array = false;
78
-        if(array_key_exists($key, $properties)) {
78
+        if (array_key_exists($key, $properties)) {
79 79
             $type = $properties[$key];
80
-            if(preg_match('/(\[\]|Array)/i', $type)) {
80
+            if (preg_match('/(\[\]|Array)/i', $type)) {
81 81
                 $type = preg_replace('/(\[\]|Array)/i', '', $type);
82 82
                 $is_array = true;
83 83
             }
84 84
         }
85 85
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
86
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
87
-            if($is_array) {
86
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
87
+            if ($is_array) {
88 88
                 $this->$key = [];
89
-                foreach($value as $data) {
89
+                foreach ($value as $data) {
90 90
                     $dto = new $type(false);
91 91
                     $dto->fromArray($data);
92 92
                     $this->$key[] = $dto;
93 93
                 }
94
-            } else {
94
+            }else {
95 95
                 $this->$key = new $type(false);
96 96
                 $this->$key->fromArray($value);
97 97
             }
98
-        } else {
99
-            switch($type) {
98
+        }else {
99
+            switch ($type) {
100 100
                 default:
101 101
                 case 'string':
102 102
                     $this->$key = $value;
Please login to merge, or discard this patch.