@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | { |
25 | 25 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
26 | 26 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
27 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
27 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
28 | 28 | $reflectionClass = new ReflectionClass($actionClass); |
29 | 29 | if ($reflectionClass->hasMethod('getInstance')) { |
30 | 30 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | $class = new $actionClass; |
33 | 33 | } |
34 | 34 | return $class; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public static function extractComponents($route, $pattern) |
63 | 63 | { |
64 | 64 | Inspector::stats('[RouterHelper] Extracting parts for the request to execute', Inspector::SCOPE_DEBUG); |
65 | - if(Config::getParam('allow.double.slashes', true)) { |
|
65 | + if (Config::getParam('allow.double.slashes', true)) { |
|
66 | 66 | $route = preg_replace("/\/\//", '/', $route); |
67 | 67 | } |
68 | 68 | $url = parse_url($route); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $cleanPatternSep--; |
101 | 101 | } |
102 | 102 | |
103 | - if(Config::getParam('allow.double.slashes', true)) { |
|
103 | + if (Config::getParam('allow.double.slashes', true)) { |
|
104 | 104 | $path = preg_replace("/\/\//", '/', $path); |
105 | 105 | } |
106 | 106 | $pathSep = count(explode('/', $path)); |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function matchRoutePattern($routePattern, $path) |
122 | 122 | { |
123 | - if(Config::getParam('allow.double.slashes', true)) { |
|
123 | + if (Config::getParam('allow.double.slashes', true)) { |
|
124 | 124 | $path = preg_replace("/\/\//", '/', $path); |
125 | 125 | } |
126 | 126 | $expr = preg_replace('/\{([^}]+)\}/', '%%%', $routePattern); |
127 | 127 | $expr = preg_quote($expr, '/'); |
128 | 128 | $expr = str_replace('%%%', '(.*)', $expr); |
129 | 129 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
130 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
130 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
131 | 131 | return $matched; |
132 | 132 | } |
133 | 133 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public static function extractDomainInfo(ReflectionClass $class, $domain) |
140 | 140 | { |
141 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
141 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
142 | 142 | $templatesPath = 'templates'; |
143 | 143 | $publicPath = 'public'; |
144 | 144 | $modelsPath = 'models'; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $modelsPath = ucfirst($modelsPath); |
149 | 149 | } |
150 | 150 | if ($class->hasConstant('TPL')) { |
151 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
151 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
152 | 152 | } |
153 | 153 | return [ |
154 | 154 | 'base' => $path, |
155 | - 'template' => $path . $templatesPath, |
|
156 | - 'model' => $path . $modelsPath, |
|
157 | - 'public' => $path . $publicPath, |
|
155 | + 'template' => $path.$templatesPath, |
|
156 | + 'model' => $path.$modelsPath, |
|
157 | + 'public' => $path.$publicPath, |
|
158 | 158 | ]; |
159 | 159 | } |
160 | 160 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | foreach ($parameters as $param) { |
176 | 176 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
177 | 177 | $params[$param->getName()] = $param->getDefaultValue(); |
178 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
178 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
179 | 179 | } elseif (!$param->isOptional()) { |
180 | 180 | $requirements[] = $param->getName(); |
181 | 181 | } |
182 | 182 | } |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | $default = $regex; |
185 | 185 | } |
186 | 186 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $httpMethod = AnnotationHelper::extractReflectionHttpMethod($docComments); |
211 | 211 | $icon = AnnotationHelper::extractDocIcon($docComments); |
212 | 212 | $label = AnnotationHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
213 | - $route = $httpMethod . "#|#" . $regex; |
|
213 | + $route = $httpMethod."#|#".$regex; |
|
214 | 214 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
215 | 215 | $info = [ |
216 | 216 | 'method' => $method->getName(), |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | protected $isMultipart = false; |
78 | 78 | |
79 | 79 | protected function closeConnection(): void { |
80 | - if(null !== $this?->con) { |
|
81 | - if($this?->con instanceof \CurlHandle) { |
|
80 | + if (null !== $this?->con) { |
|
81 | + if ($this?->con instanceof \CurlHandle) { |
|
82 | 82 | curl_close($this->con); |
83 | 83 | } |
84 | 84 | $this->setCon(null); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $this->params = []; |
96 | 96 | $this->headers = []; |
97 | - Logger::log('Context service for ' . static::class . ' cleared!'); |
|
97 | + Logger::log('Context service for '.static::class.' cleared!'); |
|
98 | 98 | $this->closeConnection(); |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $this->clearContext(); |
104 | 104 | $con = curl_init($this->url); |
105 | - if($con instanceof \CurlHandle) { |
|
105 | + if ($con instanceof \CurlHandle) { |
|
106 | 106 | $this->setCon($con); |
107 | 107 | } |
108 | 108 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public function setUrl(string $url, bool $cleanContext = true): void |
123 | 123 | { |
124 | 124 | $this->url = $url; |
125 | - if($cleanContext) { |
|
125 | + if ($cleanContext) { |
|
126 | 126 | $this->initialize(); |
127 | 127 | } |
128 | 128 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function setIsJson($isJson = true) { |
189 | 189 | $this->isJson = $isJson; |
190 | - if($isJson) { |
|
190 | + if ($isJson) { |
|
191 | 191 | $this->setIsMultipart(false); |
192 | 192 | } |
193 | 193 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function setIsMultipart($isMultipart = true) { |
206 | 206 | $this->isMultipart = $isMultipart; |
207 | - if($isMultipart) { |
|
207 | + if ($isMultipart) { |
|
208 | 208 | $this->setIsJson(false); |
209 | 209 | } |
210 | 210 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function getParams() |
19 | 19 | { |
20 | - return $this->params?: []; |
|
20 | + return $this->params ?: []; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return ParameterTrait |
50 | 50 | */ |
51 | 51 | public function dropParam($key) { |
52 | - if(array_key_exists($key, $this->params)) { |
|
52 | + if (array_key_exists($key, $this->params)) { |
|
53 | 53 | unset($this->params[$key]); |
54 | 54 | } |
55 | 55 | return $this; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return mixed|null |
61 | 61 | */ |
62 | 62 | public function getParam($key) { |
63 | - if(array_key_exists($key, $this->params)) { |
|
63 | + if (array_key_exists($key, $this->params)) { |
|
64 | 64 | return $this->params[$key]; |
65 | 65 | } |
66 | 66 | return null; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | foreach ($domains as $domain => $routes) { |
36 | 36 | $pDomain = str_replace('@', '', $domain); |
37 | 37 | $pDomain = str_replace('/', '', $pDomain); |
38 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
38 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
39 | 39 | } |
40 | 40 | return $this->json($response); |
41 | 41 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function config() |
53 | 53 | { |
54 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
55 | - if(defined('PSFS_UNIT_TESTING_EXECUTION')) { |
|
54 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
55 | + if (defined('PSFS_UNIT_TESTING_EXECUTION')) { |
|
56 | 56 | throw new ConfigException('CONFIG'); |
57 | 57 | } |
58 | 58 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | Security::getInstance()->setFlash("callback_message", t("Configuración actualizada correctamente")); |
91 | 91 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
92 | - } else { |
|
92 | + }else { |
|
93 | 93 | throw new HttpException(t('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
94 | 94 | } |
95 | 95 | } |