Passed
Push — master ( e9553e...08b58a )
by Fran
05:36 queued 11s
created
src/base/dto/Dto.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     public function __construct($hydrate = true)
16 16
     {
17 17
         parent::__construct();
18
-        if($hydrate) {
18
+        if ($hydrate) {
19 19
             $this->fromArray(Request::getInstance()->getData());
20 20
         }
21 21
     }
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
                 /** @var \ReflectionProperty $property */
44 44
                 foreach ($properties as $property) {
45 45
                     $value = $property->getValue($this);
46
-                    if(is_object($value) && method_exists($value, 'toArray')) {
46
+                    if (is_object($value) && method_exists($value, 'toArray')) {
47 47
                         $dto[$property->getName()] = $value->toArray();
48
-                    } elseif(is_array($value)) {
49
-                        foreach($value as &$arrValue) {
50
-                            if($arrValue instanceof Dto) {
48
+                    } elseif (is_array($value)) {
49
+                        foreach ($value as &$arrValue) {
50
+                            if ($arrValue instanceof Dto) {
51 51
                                 $arrValue = $arrValue->toArray();
52 52
                             }
53 53
                         }
54 54
                         $dto[$property->getName()] = $value;
55
-                    } else {
55
+                    }else {
56 56
                         $dto[$property->getName()] = $property->getValue($this);
57 57
                     }
58 58
                 }
59 59
             }
60
-        } catch (\Exception $e) {
61
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
60
+        }catch (\Exception $e) {
61
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
62 62
         }
63 63
         return $dto;
64 64
     }
@@ -80,32 +80,32 @@  discard block
 block discarded – undo
80 80
     protected function parseDtoField(array $properties, $key, $value = null) {
81 81
         $type = 'string';
82 82
         $is_array = false;
83
-        if(array_key_exists($key, $properties)) {
83
+        if (array_key_exists($key, $properties)) {
84 84
             $type = $properties[$key];
85
-            if(preg_match('/(\[\]|Array)/i', $type)) {
85
+            if (preg_match('/(\[\]|Array)/i', $type)) {
86 86
                 $type = preg_replace('/(\[\]|Array)/i', '', $type);
87 87
                 $is_array = true;
88 88
             }
89 89
         }
90 90
         $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null;
91
-        if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
92
-            if(null !== $value && is_array($value)) {
93
-                if($is_array) {
91
+        if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) {
92
+            if (null !== $value && is_array($value)) {
93
+                if ($is_array) {
94 94
                     $this->$key = [];
95
-                    foreach($value as $data) {
96
-                        if(null !== $data && is_array($data)) {
95
+                    foreach ($value as $data) {
96
+                        if (null !== $data && is_array($data)) {
97 97
                             $dto = new $type(false);
98 98
                             $dto->fromArray($data);
99 99
                             array_push($this->$key, $dto);
100 100
                         }
101 101
                     }
102
-                } else {
102
+                }else {
103 103
                     $this->$key = new $type(false);
104 104
                     $this->$key->fromArray($value);
105 105
                 }
106 106
             }
107
-        } else {
108
-            switch($type) {
107
+        }else {
108
+            switch ($type) {
109 109
                 default:
110 110
                 case 'string':
111 111
                     $this->$key = $value;
Please login to merge, or discard this patch.
src/base/types/traits/JsonTrait.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function json($response, $statusCode = 200)
27 27
     {
28
-        if(Config::getParam('profiling.enable')) {
29
-            if(is_array($response)) {
28
+        if (Config::getParam('profiling.enable')) {
29
+            if (is_array($response)) {
30 30
                 $response['profiling'] = Inspector::getStats();
31
-            } elseif($response instanceof JsonResponse) {
31
+            } elseif ($response instanceof JsonResponse) {
32 32
                 $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats());
33 33
             }
34 34
         }
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
         $this->decodeJsonResponse($response);
37 37
 
38 38
         $mask = JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING;
39
-        if(Config::getParam('output.json.strict_numbers')) {
39
+        if (Config::getParam('output.json.strict_numbers')) {
40 40
             $mask = JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK;
41 41
         }
42 42
 
43 43
         $data = json_encode($response, $mask);
44
-        if(json_last_error() !== JSON_ERROR_NONE) {
44
+        if (json_last_error() !== JSON_ERROR_NONE) {
45 45
             Logger::log(json_last_error_msg(), LOG_CRIT);
46 46
         }
47 47
 
48
-        if(Config::getParam('angular.protection', false)) {
49
-            $data = ")]}',\n" . $data;
48
+        if (Config::getParam('angular.protection', false)) {
49
+            $data = ")]}',\n".$data;
50 50
         }
51 51
         $this->setStatus($statusCode);
52 52
         ResponseHelper::setDebugHeaders([]);
Please login to merge, or discard this patch.