@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | private static function searchPayloadParam($params, $variable) { |
16 | 16 | $exists = false; |
17 | - if(null !== $params && count($params)) { |
|
18 | - foreach($params as $param) { |
|
19 | - if($param['name'] === $variable) { |
|
17 | + if (null !== $params && count($params)) { |
|
18 | + foreach ($params as $param) { |
|
19 | + if ($param['name'] === $variable) { |
|
20 | 20 | $exists = true; |
21 | 21 | break; |
22 | 22 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | ]; |
41 | 41 | if ($endpoint['payload']['is_array']) { |
42 | 42 | $schema['items'] = [ |
43 | - '$ref' => '#/definitions/' . $endpoint['payload']['type'], |
|
43 | + '$ref' => '#/definitions/'.$endpoint['payload']['type'], |
|
44 | 44 | ]; |
45 | - } else { |
|
46 | - $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type']; |
|
45 | + }else { |
|
46 | + $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type']; |
|
47 | 47 | } |
48 | - if(!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) { |
|
48 | + if (!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) { |
|
49 | 49 | $paths[$url][$method]['parameters'][] = [ |
50 | 50 | 'in' => 'body', |
51 | 51 | 'name' => $endpoint['payload']['type'], |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
75 | 75 | $classDefinition = [ |
76 | 76 | 'type' => 'object', |
77 | - '$ref' => '#/definitions/' . $class, |
|
77 | + '$ref' => '#/definitions/'.$class, |
|
78 | 78 | ]; |
79 | - } else { |
|
79 | + }else { |
|
80 | 80 | $classDefinition = [ |
81 | 81 | 'type' => 'array', |
82 | 82 | 'items' => [ |
83 | - '$ref' => '#/definitions/' . $class, |
|
83 | + '$ref' => '#/definitions/'.$class, |
|
84 | 84 | ], |
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | |
88 | - if($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') { |
|
88 | + if ($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') { |
|
89 | 89 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; |
90 | 90 | } |
91 | 91 | $dtos += self::extractSwaggerDefinition($class, $object); |
@@ -163,18 +163,18 @@ discard block |
||
163 | 163 | ], |
164 | 164 | ]; |
165 | 165 | foreach ($fields as $field => $info) { |
166 | - if(array_key_exists('type', $info) && in_array($info['type'], ['array', 'object'])) { |
|
166 | + if (array_key_exists('type', $info) && in_array($info['type'], ['array', 'object'])) { |
|
167 | 167 | $definition[$name]['properties'][$field] = $info; |
168 | - } elseif(array_key_exists('type', $info)) { |
|
168 | + } elseif (array_key_exists('type', $info)) { |
|
169 | 169 | list($type, $format) = self::translateSwaggerFormats($info['type']); |
170 | 170 | $fieldData = [ |
171 | 171 | "type" => $type, |
172 | 172 | "required" => $info['required'], |
173 | 173 | ]; |
174 | - if(array_key_exists('description', $info)) { |
|
174 | + if (array_key_exists('description', $info)) { |
|
175 | 175 | $fieldData['description'] = $info['description']; |
176 | 176 | } |
177 | - if(array_key_exists('format', $info)) { |
|
177 | + if (array_key_exists('format', $info)) { |
|
178 | 178 | $fieldData['format'] = $info['format']; |
179 | 179 | } |
180 | 180 | $dto['properties'][$field] = $fieldData; |
@@ -15,7 +15,7 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -25,10 +25,10 @@ discard block |
||
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 |
||
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([]); |