@@ -72,8 +72,9 @@ |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function setCallable($callback) { |
75 | - if (is_callable($callback)) |
|
76 | - $this->callable = $callback; |
|
75 | + if (is_callable($callback)) { |
|
76 | + $this->callable = $callback; |
|
77 | + } |
|
77 | 78 | } |
78 | 79 | |
79 | 80 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | private $argsPattern = "(\\w+)"; |
62 | 62 | |
63 | 63 | public function __construct($pattern, $callable) { |
64 | - $this->argsPattern = self::PARAMETER_CHARACTER . $this->argsPattern; |
|
64 | + $this->argsPattern = self::PARAMETER_CHARACTER.$this->argsPattern; |
|
65 | 65 | $this->setPattern($pattern); |
66 | 66 | $this->setCallable($callable); |
67 | 67 | $this->filterPattern(); |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | $pattern = $this->getPattern(); |
72 | 72 | $match = []; |
73 | 73 | $pattern = str_replace("/", "\\/", $pattern); |
74 | - if (preg_match_all("/" . $this->argsPattern . "/", $pattern, $match)) { |
|
74 | + if (preg_match_all("/".$this->argsPattern."/", $pattern, $match)) { |
|
75 | 75 | $strings = $match[0]; |
76 | 76 | $parameters = $match[1]; |
77 | 77 | $this->params = $parameters; |
78 | 78 | $pattern = str_replace($strings, str_replace(self::PARAMETER_CHARACTER, "", $this->argsPattern), $pattern); |
79 | 79 | } |
80 | - $this->setPattern("/^" . $pattern . "$/"); |
|
80 | + $this->setPattern("/^".$pattern."$/"); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function setPattern($pattern) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // Get the substring after $substrToRemove |
54 | 54 | $post = substr($string, $lastIndex); |
55 | 55 | // Return $pre and $post |
56 | - return $pre . $post; |
|
56 | + return $pre.$post; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public static function addTrailingSlash($path) { |
78 | 78 | if (null !== $path && is_string($path) && !empty($path)) { |
79 | 79 | if (substr($path, -1) !== "/") { |
80 | - $path .="/"; |
|
80 | + $path .= "/"; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | return $path; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return string |
102 | 102 | */ |
103 | 103 | public static function removeDouble($string, $substring) { |
104 | - return str_replace($substring . $substring, $substring, $string); |
|
104 | + return str_replace($substring.$substring, $substring, $string); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | <body> |
181 | 181 | <h1>Tight Framework Exception</h1> |
182 | 182 | EXC; |
183 | - $output .= "<p><strong>" . get_class($exception) . ": </strong>" . $exception->getMessage() . "</p>"; |
|
184 | - $output .= "<p class='padding-left'>in <strong>" . $lastTrace['file'] . "</strong> at line <strong>" . $lastTrace['line'] . "</strong></p>"; |
|
183 | + $output .= "<p><strong>".get_class($exception).": </strong>".$exception->getMessage()."</p>"; |
|
184 | + $output .= "<p class='padding-left'>in <strong>".$lastTrace['file']."</strong> at line <strong>".$lastTrace['line']."</strong></p>"; |
|
185 | 185 | $output .= "<br/>"; |
186 | 186 | $output .= "<p>Stack Trace:</p>"; |
187 | 187 | $trace = $exception->getTrace(); |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | $class = isset($element["class"]) ? $element["class"] : ""; |
192 | 192 | $type = isset($element["type"]) ? $element["type"] : ""; |
193 | 193 | $func = isset($element["function"]) ? $element["function"] : ""; |
194 | - $file = isset($element["file"]) ? "at <strong>" . $element["file"] . "</strong>" : ""; |
|
195 | - $line = isset($element["line"]) ? " at line <strong>" . $element["line"] . "</strong>" : ""; |
|
196 | - $output .= "<p>#" . ($index + 1) . ": " . $class . $type . $func . "() " . $file . $line . "</strong></p>"; |
|
194 | + $file = isset($element["file"]) ? "at <strong>".$element["file"]."</strong>" : ""; |
|
195 | + $line = isset($element["line"]) ? " at line <strong>".$element["line"]."</strong>" : ""; |
|
196 | + $output .= "<p>#".($index + 1).": ".$class.$type.$func."() ".$file.$line."</strong></p>"; |
|
197 | 197 | } |
198 | 198 | echo $output; |
199 | 199 | } |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @covers Tight\Router::__construct |
41 | 41 | */ |
42 | 42 | public function setUp() { |
43 | - $dirs = ["models","views","controllers"]; |
|
43 | + $dirs = ["models", "views", "controllers"]; |
|
44 | 44 | $size = count($dirs); |
45 | 45 | for ($index = 0; $index < $size; $index++) { |
46 | - if(!is_dir($dirs[$index])){ |
|
46 | + if (!is_dir($dirs[$index])) { |
|
47 | 47 | mkdir($dirs[$index]); |
48 | 48 | } |
49 | 49 | } |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | return "Hello"; |
53 | 53 | }); |
54 | 54 | $this->router->get("/hello/:id", function($id) { |
55 | - return "Hello " . $id; |
|
55 | + return "Hello ".$id; |
|
56 | 56 | }); |
57 | 57 | $this->router->post("/world/", function() { |
58 | 58 | return "world"; |
59 | 59 | }); |
60 | 60 | $this->router->post("/world/:id", function($id) { |
61 | - return $id . " world"; |
|
61 | + return $id." world"; |
|
62 | 62 | }); |
63 | 63 | $this->router->map(["get", "post"], "/map/", function() { |
64 | 64 | return "map"; |
@@ -107,7 +107,7 @@ |
||
107 | 107 | unset($app); |
108 | 108 | $app = new \Tight\Tight; |
109 | 109 | $app->setConfig($this->config); |
110 | - $this->assertEquals($expectedClass,$app->getConfig()); |
|
110 | + $this->assertEquals($expectedClass, $app->getConfig()); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | $pattern = array_shift($args); // 1st index-> Pattern |
173 | 173 | $callable = array_pop($args); // Last index-> callable |
174 | - $route = new Route(Utils::removeDouble($this->basePath . $pattern, "/"), $callable); |
|
174 | + $route = new Route(Utils::removeDouble($this->basePath.$pattern, "/"), $callable); |
|
175 | 175 | $route->setHttpMethods($methods); |
176 | 176 | if (count($args) > 0) { |
177 | 177 | // Adds the middleware |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return string Request URN |
248 | 248 | */ |
249 | 249 | public function getRequestUrn() { |
250 | - $output = Utils::addTrailingSlash("/" . Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath)); |
|
250 | + $output = Utils::addTrailingSlash("/".Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath)); |
|
251 | 251 | return $output; |
252 | 252 | } |
253 | 253 | |
@@ -265,22 +265,22 @@ discard block |
||
265 | 265 | $viewDir = $config->mvc["view_dir"]; |
266 | 266 | if (is_dir($controllerDir) && is_dir($modelDir) && is_dir($viewDir)) { |
267 | 267 | if (strpos(strtolower($className), "controller") !== FALSE) { |
268 | - if (is_file($controllerDir . $className . ".php")) { |
|
269 | - require_once $controllerDir . $className . ".php"; |
|
268 | + if (is_file($controllerDir.$className.".php")) { |
|
269 | + require_once $controllerDir.$className.".php"; |
|
270 | 270 | } else { |
271 | - $fileNotFound = $controllerDir . $className . ".php"; |
|
271 | + $fileNotFound = $controllerDir.$className.".php"; |
|
272 | 272 | } |
273 | 273 | } elseif (strpos(strtolower($className), "model") !== FALSE) { |
274 | - if (is_file($modelDir . $className . ".php")) { |
|
275 | - require_once $modelDir . $className . ".php"; |
|
274 | + if (is_file($modelDir.$className.".php")) { |
|
275 | + require_once $modelDir.$className.".php"; |
|
276 | 276 | } else { |
277 | - $fileNotFound = $modelDir . $className . ".php"; |
|
277 | + $fileNotFound = $modelDir.$className.".php"; |
|
278 | 278 | } |
279 | 279 | } elseif (strpos(strtolower($className), "view") !== FALSE) { |
280 | - if (is_file($viewDir . $className . ".php")) { |
|
281 | - require_once $viewDir . $className . ".php"; |
|
280 | + if (is_file($viewDir.$className.".php")) { |
|
281 | + require_once $viewDir.$className.".php"; |
|
282 | 282 | } else { |
283 | - $fileNotFound = $viewDir . $className . ".php"; |
|
283 | + $fileNotFound = $viewDir.$className.".php"; |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | } else { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $err = !is_dir($controllerDir) ? "Controller directory not found" : !is_dir($modelDir) ? "Model directory not found" : "View directory not found"; |
291 | 291 | throw new \Tight\Exception\NotFoundException($err); |
292 | 292 | } else if ($fileNotFound !== false) { |
293 | - $err = "File <strong>" . $fileNotFound . "</strong> not found"; |
|
293 | + $err = "File <strong>".$fileNotFound."</strong> not found"; |
|
294 | 294 | throw new \Tight\Exception\NotFoundException($err); |
295 | 295 | } |
296 | 296 | } |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | } |
317 | 317 | } |
318 | 318 | $name = ucwords($name); |
319 | - $contName = $name . "Controller"; |
|
320 | - $viewName = $name . "View"; |
|
321 | - $modName = $name . "Model"; |
|
319 | + $contName = $name."Controller"; |
|
320 | + $viewName = $name."View"; |
|
321 | + $modName = $name."Model"; |
|
322 | 322 | $model = new $modName(); |
323 | 323 | $view = new $viewName(); |
324 | 324 | $controller = new $contName($model, $view); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | if (method_exists($controller, $method)) { |
327 | 327 | call_user_method_array($method, $controller, $args); |
328 | 328 | } else { |
329 | - throw new \Tight\Exception\RouterException("Method <strong>" . $method . "</strong> not defined for <strong>" . $contName . "</strong> class"); |
|
329 | + throw new \Tight\Exception\RouterException("Method <strong>".$method."</strong> not defined for <strong>".$contName."</strong> class"); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | $controller->render(); |
@@ -62,7 +62,7 @@ |
||
62 | 62 | $this->modules[$module->getModuleName()] = $module; |
63 | 63 | $module->onLoad(); |
64 | 64 | } else { |
65 | - throw new \Tight\Exception\ModuleException("Module <strong>" . $module->getModuleName() . "</strong> already exists"); |
|
65 | + throw new \Tight\Exception\ModuleException("Module <strong>".$module->getModuleName()."</strong> already exists"); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function testUtilsAddTrailingSlash() { |
74 | 74 | $path = "/etc/php5"; |
75 | 75 | $this->assertEquals("/etc/php5/", Utils::addTrailingSlash($path)); |
76 | - $this->assertEquals("/etc/php5/", Utils::addTrailingSlash($path . "/")); |
|
76 | + $this->assertEquals("/etc/php5/", Utils::addTrailingSlash($path."/")); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $pathUnx = "/var/htdocs"; |
85 | 85 | $this->assertEquals("C:/php/ext/", Utils::filterPath($pathWin)); |
86 | 86 | $this->assertEquals("/var/htdocs/", Utils::filterPath($pathUnx)); |
87 | - $this->assertEquals("/var/htdocs/", Utils::filterPath($pathUnx . "/")); |
|
87 | + $this->assertEquals("/var/htdocs/", Utils::filterPath($pathUnx."/")); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * @test |
111 | 111 | */ |
112 | - public function testUtilsStartsWith(){ |
|
112 | + public function testUtilsStartsWith() { |
|
113 | 113 | $string = "abcd"; |
114 | 114 | $this->assertTrue(Utils::startsWith("abcd", "abc")); |
115 | 115 | $this->assertFalse(Utils::startsWith("abcd", "cd")); |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | private $module; |
92 | 92 | |
93 | 93 | public function setUp() { |
94 | - $valuesFile_en = self::$resourceFolder . "/values.json"; |
|
95 | - $valuesFile_es = self::$resourceFolder . "/values_es.json"; |
|
96 | - $valuesFile_fr = self::$resourceFolder . "/values_fr.json"; |
|
97 | - $valuesXml = self::$resourceFolder . "/values.xml"; |
|
94 | + $valuesFile_en = self::$resourceFolder."/values.json"; |
|
95 | + $valuesFile_es = self::$resourceFolder."/values_es.json"; |
|
96 | + $valuesFile_fr = self::$resourceFolder."/values_fr.json"; |
|
97 | + $valuesXml = self::$resourceFolder."/values.xml"; |
|
98 | 98 | if (!is_dir(self::$resourceFolder)) { |
99 | 99 | mkdir(self::$resourceFolder); |
100 | 100 | } |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | file_put_contents($valuesXml, $this->valuesXml); |
112 | 112 | } |
113 | 113 | $this->config = [ |
114 | - "resourceFolder" => "./" . self::$resourceFolder . "/" |
|
114 | + "resourceFolder" => "./".self::$resourceFolder."/" |
|
115 | 115 | ]; |
116 | 116 | $this->module = new \Tight\Modules\Localize\Localize($this->config); |
117 | 117 | } |
118 | 118 | |
119 | 119 | public function tearDown() { |
120 | - $valuesFile_en = self::$resourceFolder . "/values.json"; |
|
121 | - $valuesFile_es = self::$resourceFolder . "/values_es.json"; |
|
122 | - $valuesFile_fr = self::$resourceFolder . "/values_fr.json"; |
|
123 | - $valuesXml = self::$resourceFolder . "/values.xml"; |
|
120 | + $valuesFile_en = self::$resourceFolder."/values.json"; |
|
121 | + $valuesFile_es = self::$resourceFolder."/values_es.json"; |
|
122 | + $valuesFile_fr = self::$resourceFolder."/values_fr.json"; |
|
123 | + $valuesXml = self::$resourceFolder."/values.xml"; |
|
124 | 124 | $files = [$valuesFile_en, $valuesFile_es, $valuesFile_fr, $valuesXml]; |
125 | 125 | $size = count($files); |
126 | 126 | for ($index = 0; $index < $size; $index++) { |