Completed
Push — master ( f77736...9f4e3e )
by Alejandro
02:55
created
src/Route.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Utils.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
tests/UtilsTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Router.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
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
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @return string Request URN
247 247
      */
248 248
     public function getRequestUrn() {
249
-        $output = Utils::addTrailingSlash("/" . Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath));
249
+        $output = Utils::addTrailingSlash("/".Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath));
250 250
         return $output;
251 251
     }
252 252
 
@@ -264,22 +264,22 @@  discard block
 block discarded – undo
264 264
         $viewDir = $config->mvc["view_dir"];
265 265
         if (is_dir($controllerDir) && is_dir($modelDir) && is_dir($viewDir)) {
266 266
             if (strpos(strtolower($className), "controller") !== FALSE) {
267
-                if (is_file($controllerDir . $className . ".php")) {
268
-                    require_once $controllerDir . $className . ".php";
267
+                if (is_file($controllerDir.$className.".php")) {
268
+                    require_once $controllerDir.$className.".php";
269 269
                 } else {
270
-                    $fileNotFound = $controllerDir . $className . ".php";
270
+                    $fileNotFound = $controllerDir.$className.".php";
271 271
                 }
272 272
             } elseif (strpos(strtolower($className), "model") !== FALSE) {
273
-                if (is_file($modelDir . $className . ".php")) {
274
-                    require_once $modelDir . $className . ".php";
273
+                if (is_file($modelDir.$className.".php")) {
274
+                    require_once $modelDir.$className.".php";
275 275
                 } else {
276
-                    $fileNotFound = $modelDir . $className . ".php";
276
+                    $fileNotFound = $modelDir.$className.".php";
277 277
                 }
278 278
             } elseif (strpos(strtolower($className), "view") !== FALSE) {
279
-                if (is_file($viewDir . $className . ".php")) {
280
-                    require_once $viewDir . $className . ".php";
279
+                if (is_file($viewDir.$className.".php")) {
280
+                    require_once $viewDir.$className.".php";
281 281
                 } else {
282
-                    $fileNotFound = $viewDir . $className . ".php";
282
+                    $fileNotFound = $viewDir.$className.".php";
283 283
                 }
284 284
             }
285 285
         } else {
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             $err = !is_dir($controllerDir) ? "Controller directory cant be found" : !is_dir($modelDir) ? "Model directory cant be found" : "View directory cant be found";
290 290
             throw new \Tight\Exception\FileNotFoundException($err);
291 291
         } else if ($fileNotFound) {
292
-            $err = "File <strong>" . $fileNotFound . "</strong> not found";
292
+            $err = "File <strong>".$fileNotFound."</strong> not found";
293 293
             throw new \Tight\Exception\FileNotFoundException($err);
294 294
         }
295 295
     }
@@ -316,9 +316,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
326 326
                 if (method_exists($controller, $method)) {
327 327
                     call_user_method_array($method, $controller, $args);
328 328
                 } else {
329
-                    throw new \Tight\Exception\FileNotFoundException("Method <strong>" . $method . "</strong> not defined for <strong>" . $contName . "</strong> class");
329
+                    throw new \Tight\Exception\FileNotFoundException("Method <strong>".$method."</strong> not defined for <strong>".$contName."</strong> class");
330 330
                 }
331 331
             }
332 332
             $controller->render();
Please login to merge, or discard this patch.
src/Modules/Localize/Localize.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         if (is_array($config)) {
44 44
             $config = new LocalizeConfig($config);
45 45
         } else if (!is_a($config, "\Tight\Modules\Localize\LocalizeConfig")) {
46
-            throw new \InvalidArgumentException("Argument 1 passed to " . get_class($this) . " must be an array or an instance of Tight\Modules\Localize\LocalizeConfig");
46
+            throw new \InvalidArgumentException("Argument 1 passed to ".get_class($this)." must be an array or an instance of Tight\Modules\Localize\LocalizeConfig");
47 47
         }
48 48
         parent::__construct();
49 49
         $this->setConfig($config);
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
     public function setLocale($locale) {
80 80
         $this->locale = $locale;
81 81
         $folder = \Tight\Utils::addTrailingSlash($this->config->resourceFolder);
82
-        $fileName = $this->config->resourceFileName . $this->config->langSeparator . $locale . "." . $this->config->resourceFileType;
83
-        $file = $folder . $fileName;
82
+        $fileName = $this->config->resourceFileName.$this->config->langSeparator.$locale.".".$this->config->resourceFileType;
83
+        $file = $folder.$fileName;
84 84
         if (is_file($file)) {
85 85
             $this->values = json_decode(file_get_contents($file), JSON_FORCE_OBJECT);
86 86
         } else {
87
-            $fileName = $this->config->resourceFileName . "." . $this->config->resourceFileType;
88
-            $file = $folder . $fileName;
87
+            $fileName = $this->config->resourceFileName.".".$this->config->resourceFileType;
88
+            $file = $folder.$fileName;
89 89
             if (is_file($file)) {
90 90
                 $this->values = json_decode(file_get_contents($file), JSON_FORCE_OBJECT);
91 91
             } else {
92
-                throw new \Tight\Modules\ModuleException("Resource file <strong>" . $file . "</strong> not found");
92
+                throw new \Tight\Modules\ModuleException("Resource file <strong>".$file."</strong> not found");
93 93
             }
94 94
         }
95 95
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             }
116 116
         }
117 117
         foreach ($files as $element) {
118
-            $file = \Tight\Utils::getSlicedFile($directory . $element);
118
+            $file = \Tight\Utils::getSlicedFile($directory.$element);
119 119
             //Removes extension
120 120
             $name = $file["name"];
121 121
             $explode = explode($this->config->langSeparator, $name);
Please login to merge, or discard this patch.
tests/LocalizeModuleTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
     private $module;
63 63
 
64 64
     public function setUp() {
65
-        $valuesFile_en = self::$resourceFolder . "/values.json";
66
-        $valuesFile_es = self::$resourceFolder . "/values_es.json";
67
-        $valuesFile_fr = self::$resourceFolder . "/values_fr.json";
65
+        $valuesFile_en = self::$resourceFolder."/values.json";
66
+        $valuesFile_es = self::$resourceFolder."/values_es.json";
67
+        $valuesFile_fr = self::$resourceFolder."/values_fr.json";
68 68
         if (!is_dir(self::$resourceFolder)) {
69 69
             mkdir(self::$resourceFolder);
70 70
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             file_put_contents($valuesFile_fr, json_encode($this->locale_fr));
79 79
         }
80 80
         $this->config = [
81
-            "resourceFolder" => "./" . self::$resourceFolder . "/"
81
+            "resourceFolder" => "./".self::$resourceFolder."/"
82 82
         ];
83 83
         $this->module = new \Tight\Modules\Localize\Localize($this->config);
84 84
     }
Please login to merge, or discard this patch.
src/Tight.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
tests/RouterTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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";
Please login to merge, or discard this patch.