Passed
Branch master (9f48fa)
by César
04:10
created
src/Route.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
      * @param $url
46 46
      * @return bool
47 47
      */
48
-    public function match($url){
48
+    public function match($url) {
49 49
         $url = trim($url, '/');
50 50
         $path = preg_replace('#:([\w]+)#', '([^/]+)', $this->getUrl());
51 51
         $regex = "#^$path$#i";
52
-        if(!preg_match($regex, $url, $matches)){
52
+        if (!preg_match($regex, $url, $matches)) {
53 53
             return false;
54 54
         }
55 55
         array_shift($matches);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function getParams(): array
86 86
     {
87
-        return array_merge($this->params, [ $this->request ]);
87
+        return array_merge($this->params, [$this->request]);
88 88
     }
89 89
 
90 90
     /**
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
      */
95 95
     private function prepareController()
96 96
     {
97
-        RouteController::format( $this->getCallable() );
98
-        return call_user_func_array( [ RouteController::getClass(), RouteController::getMethod()], $this->getParams() );
97
+        RouteController::format($this->getCallable());
98
+        return call_user_func_array([RouteController::getClass(), RouteController::getMethod()], $this->getParams());
99 99
     }
100 100
 
101 101
     /**
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function run()
107 107
     {
108
-        if( is_string( $this->getCallable() ) ) {
108
+        if (is_string($this->getCallable())) {
109 109
             $this->execute = $this->prepareController();
110 110
         }
111 111
 
112
-        if( is_callable( $this->getCallable() ) ) {
113
-            $this->execute = call_user_func_array( $this->callable, $this->getParams() );
112
+        if (is_callable($this->getCallable())) {
113
+            $this->execute = call_user_func_array($this->callable, $this->getParams());
114 114
         }
115 115
 
116 116
         return $this->formatAndRespond();
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function formatAndRespond()
125 125
     {
126
-        $ws = new RouteResponse( $this->execute );
126
+        $ws = new RouteResponse($this->execute);
127 127
 
128 128
         $decorator = null;
129 129
 
130
-        if( is_string( $this->execute) ) {
131
-            $decorator = new TextPlainRenderer( $ws, $this->request);
130
+        if (is_string($this->execute)) {
131
+            $decorator = new TextPlainRenderer($ws, $this->request);
132 132
         }
133 133
 
134
-        if( is_array( $this->execute) ) {
135
-            $decorator = new JsonRenderer( $ws, $this->request);
134
+        if (is_array($this->execute)) {
135
+            $decorator = new JsonRenderer($ws, $this->request);
136 136
         }
137 137
 
138 138
         return $decorator->render();
Please login to merge, or discard this patch.
src/Response/XmlRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@
 block discarded – undo
25 25
 
26 26
         $data_format = $this->wrapped->render();
27 27
 
28
-        $this->response->setContent( $data_format );
29
-        $this->response->headers->add( $this->headers );
30
-        $this->response->prepare( $this->request );
28
+        $this->response->setContent($data_format);
29
+        $this->response->headers->add($this->headers);
30
+        $this->response->prepare($this->request);
31 31
         $this->response->send();
32 32
     }
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Response/TextPlainRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
      */
25 25
     public function render()
26 26
     {
27
-        $this->response->setContent( $this->wrapped->render() );
28
-        $this->response->headers->add( $this->headers );
29
-        $this->response->prepare( $this->request );
27
+        $this->response->setContent($this->wrapped->render());
28
+        $this->response->headers->add($this->headers);
29
+        $this->response->prepare($this->request);
30 30
         $this->response->send();
31 31
     }
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
src/Response/JsonRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
      */
25 25
     public function render()
26 26
     {
27
-        $this->response->setContent( json_encode( $this->wrapped->render() ) );
28
-        $this->response->headers->add( $this->headers );
29
-        $this->response->prepare( $this->request );
27
+        $this->response->setContent(json_encode($this->wrapped->render()));
28
+        $this->response->headers->add($this->headers);
29
+        $this->response->prepare($this->request);
30 30
         $this->response->send();
31 31
     }
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
src/Router.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
      */
112 112
     protected function checkCommonProblems()
113 113
     {
114
-         if( static::hasRouteValid() ) {
114
+            if( static::hasRouteValid() ) {
115 115
             return false;
116 116
         }
117 117
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function uri() : string
93 93
     {
94
-        return strtok( $_SERVER['REQUEST_URI'], '?');
94
+        return strtok($_SERVER['REQUEST_URI'], '?');
95 95
     }
96 96
 
97 97
     /**
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function checkCommonProblems()
113 113
     {
114
-         if( static::hasRouteValid() ) {
114
+         if (static::hasRouteValid()) {
115 115
             return false;
116 116
         }
117 117
 
118
-        if( empty( $this->routeStack) )
118
+        if (empty($this->routeStack))
119 119
         {
120 120
             throw new \InvalidArgumentException('Routing empty');
121 121
         }
122 122
 
123
-        if( !isset( $this->routeStack[static::method()] ) ){
123
+        if (!isset($this->routeStack[static::method()])) {
124 124
             throw new MethodNotAllowedException('Requested method was not scaled.');
125 125
         }
126 126
         return true;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         foreach ($this->routeStack[static::method()] as $route) {
150 150
             /** @var $route Route */
151
-            if( $route->match( $this->uri() ) ) {
151
+            if ($route->match($this->uri())) {
152 152
                 return $route->run();
153 153
             }
154 154
         }
Please login to merge, or discard this patch.