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