Completed
Push — master ( c4f7f5...ee49f4 )
by Alejandro
04:40
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 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * 
116 116
      * This method need at least 2 arguments: route pattern and callable.
117 117
      * You can create midleware callables which will be executed before the route
118
-     * @return type
118
+     * @return Router
119 119
      */
120 120
     public function post() {
121 121
         return $this->url(Route::METHOD_POST, func_get_args());
@@ -198,6 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
     /**
200 200
      * Method called when route cant be found
201
+     * @param \Closure $callback
201 202
      */
202 203
     public function notFound($callback) {
203 204
         $this->errorHandler['notFound'] = $callback;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 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
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
      * @return string Request URN
241 241
      */
242 242
     public function getRequestUrn() {
243
-        $output = Utils::addTrailingSlash("/" . Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath));
243
+        $output = Utils::addTrailingSlash("/".Utils::removeSubstring($_SERVER['REQUEST_URI'], $this->basePath));
244 244
         return $output;
245 245
     }
246 246
 
247 247
     public function runMvc() {
248 248
         //@todo Create routes depending on the request URI using MVC
249 249
         $requestUrn = $this->getRequestUrn();
250
-        if("/" == $requestUrn){
250
+        if ("/" == $requestUrn) {
251 251
             $name = \Tight\Tight::getInstance()->getConfig()->mvc["indexName"];
252 252
             echo $name;
253 253
         }
Please login to merge, or discard this patch.
tests/RouterTest.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
             echo "Hello";
44 44
         });
45 45
         $this->router->get("/hello/:id", function($id) {
46
-            echo "Hello " . $id;
46
+            echo "Hello ".$id;
47 47
         });
48 48
         $this->router->post("/world/", function() {
49 49
             echo "world";
50 50
         });
51 51
         $this->router->post("/world/:id", function($id) {
52
-            echo $id . " world";
52
+            echo $id." world";
53 53
         });
54 54
         $this->router->map(["get", "post"], "/map/", function() {
55 55
             echo "map";
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
         $this->expectOutputString("Hello");
85 85
         $output .= "Hello";
86 86
         $this->router->dispatch("/hello/", "post");
87
-        $this->expectOutputString($output . "Page not found");
87
+        $this->expectOutputString($output."Page not found");
88 88
         $output .= "Page not found";
89 89
         $this->router->dispatch("/hello/world", "get");
90
-        $this->expectOutputString($output . "Hello world");
91
-        $output.="Hello world";
90
+        $this->expectOutputString($output."Hello world");
91
+        $output .= "Hello world";
92 92
     }
93 93
 
94 94
     /**
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
     public function testRouterPost() {
100 100
         $output = "";
101 101
         $this->router->dispatch("/world/", "post");
102
-        $this->expectOutputString($output . "world");
102
+        $this->expectOutputString($output."world");
103 103
         $output .= "world";
104 104
         $this->router->dispatch("/world/", "get");
105
-        $this->expectOutputString($output . "Page not found");
105
+        $this->expectOutputString($output."Page not found");
106 106
         $output .= "Page not found";
107 107
         $this->router->dispatch("/world/hello", "post");
108
-        $this->expectOutputString($output . "hello world");
108
+        $this->expectOutputString($output."hello world");
109 109
         $output .= "Hello world";
110 110
     }
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
     public function testRouterMap() {
119 119
         $output = "";
120 120
         $this->router->dispatch("/map/", "post");
121
-        $this->expectOutputString($output . "map");
121
+        $this->expectOutputString($output."map");
122 122
         $output .= "map";
123 123
         $this->router->dispatch("/map/", "get");
124
-        $this->expectOutputString($output . "map");
124
+        $this->expectOutputString($output."map");
125 125
         $output .= "map";
126 126
         $this->router->dispatch("/map/", "options");
127
-        $this->expectOutputString($output . "Page not found");
127
+        $this->expectOutputString($output."Page not found");
128 128
         $output .= "Page not found";
129 129
     }
130 130
 
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
     public function testRouteUpdate() {
137 137
         $output = "";
138 138
         $this->router->dispatch("/upd/", "update");
139
-        $this->expectOutputString($output . "upd");
139
+        $this->expectOutputString($output."upd");
140 140
         $output .= "upd";
141 141
         $this->router->dispatch("/upd/", "get");
142
-        $this->expectOutputString($output . "Page not found");
142
+        $this->expectOutputString($output."Page not found");
143 143
         $output .= "Page not found";
144 144
     }
145 145
 
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
     public function testRouteDelete() {
152 152
         $output = "";
153 153
         $this->router->dispatch("/del/", "delete");
154
-        $this->expectOutputString($output . "del");
154
+        $this->expectOutputString($output."del");
155 155
         $output .= "del";
156 156
         $this->router->dispatch("/del/", "post");
157
-        $this->expectOutputString($output . "Page not found");
157
+        $this->expectOutputString($output."Page not found");
158 158
         $output .= "Page not found";
159 159
     }
160 160
 
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
     public function testRouteMiddleware() {
167 167
         $output = "";
168 168
         $this->router->dispatch("/middle/", "get");
169
-        $this->expectOutputString($output . "mid1 mid2 end");
169
+        $this->expectOutputString($output."mid1 mid2 end");
170 170
         $output .= "mid1 mid2 end";
171 171
         $this->router->dispatch("/middle/", "post");
172
-        $this->expectOutputString($output . "Page not found");
172
+        $this->expectOutputString($output."Page not found");
173 173
         $output .= "Page not found";
174 174
     }
175 175
 
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 24
  * THE SOFTWARE.
25 25
  */
26
-$_SERVER["DOCUMENT_ROOT"]="/var/www/";
27
-$_SERVER["REQUEST_METHOD"] ="GET";
28
-$_SERVER["REQUEST_URI"] ="/tests/";
26
+$_SERVER["DOCUMENT_ROOT"] = "/var/www/";
27
+$_SERVER["REQUEST_METHOD"] = "GET";
28
+$_SERVER["REQUEST_URI"] = "/tests/";
29 29
 require_once "./vendor/autoload.php";
30 30
\ No newline at end of file
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
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
                     <body>
137 137
                         <h1>Tight Framework Exception</h1>
138 138
 EXC;
139
-        $output .= "<p><strong>" . get_class($ex) . ": </strong>" . $ex->getMessage() . "</p>";
140
-        $output .= "<p class='padding-left'>in <strong>" . $lastTrace['file'] . "</strong> at line <strong>" . $lastTrace['line'] . "</strong></p>";
139
+        $output .= "<p><strong>".get_class($ex).": </strong>".$ex->getMessage()."</p>";
140
+        $output .= "<p class='padding-left'>in <strong>".$lastTrace['file']."</strong> at line <strong>".$lastTrace['line']."</strong></p>";
141 141
         $output .= "<br/>";
142 142
         $output .= "<p>Stack Trace:</p>";
143 143
         $trace = $ex->getTrace();
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
             $class = isset($el["class"]) ? $el["class"] : "";
147 147
             $type = isset($el["type"]) ? $el["type"] : "";
148 148
             $func = isset($el["function"]) ? $el["function"] : "";
149
-            $file = isset($el["file"]) ? "at <strong>" . $el["file"] . "</strong>" : "";
150
-            $line = isset($el["line"]) ? "at line <strong>" . $el["line"] . "</strong>" : "";
151
-            $output .= "<p>#" . ($index + 1) . ": " . $class . $type . $func . "() ". $file .  $line . "</strong></p>";
149
+            $file = isset($el["file"]) ? "at <strong>".$el["file"]."</strong>" : "";
150
+            $line = isset($el["line"]) ? "at line <strong>".$el["line"]."</strong>" : "";
151
+            $output .= "<p>#".($index + 1).": ".$class.$type.$func."() ".$file.$line."</strong></p>";
152 152
         }
153 153
         echo $output;
154 154
     }
Please login to merge, or discard this patch.