Passed
Push — master ( 91b62f...022aa2 )
by Henri
01:21
created
examples/Middleware/Middleware.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
 use Psr\Http\Server\MiddlewareInterface;
8 8
 use Psr\Http\Server\RequestHandlerInterface;
9 9
 
10
-class Middleware implements MiddlewareInterface{
10
+class Middleware implements MiddlewareInterface {
11 11
     protected static array $data = [];
12 12
 
13 13
     public function __get($key)
14 14
     {
15
-        return (array_key_exists($key,self::$data)) ? self::$data[$key] : null;
15
+        return (array_key_exists($key, self::$data)) ? self::$data[$key] : null;
16 16
     }
17 17
 
18
-    public function __set($key,$value)
18
+    public function __set($key, $value)
19 19
     {
20 20
         self::$data[$key] = $value;
21 21
     }
Please login to merge, or discard this patch.
src/RequestHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
     public function handle(ServerRequestInterface $request): ResponseInterface
15 15
     {
16
-        if(!isset(self::$response)){
16
+        if (!isset(self::$response)) {
17 17
             self::$response = new Response();
18 18
         }
19 19
 
Please login to merge, or discard this patch.
src/MiddlewareTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
 use HnrAzevedo\Http\Uri;
8 8
 use HnrAzevedo\Http\Factory;
9 9
 
10
-trait MiddlewareTrait{
10
+trait MiddlewareTrait {
11 11
     protected array $middlewares = [];
12 12
     protected RequestHandler $request;
13 13
     protected ServerRequest $serverRequest;
14 14
 
15 15
     protected function executeMiddleware(array $route)
16 16
     {
17
-        $this->request = new RequestHandler($route['protocol'],new Uri($this->host.$route['url']));  
18
-        $this->serverRequest = (new Factory())->createServerRequest($route['protocol'],new Uri($this->host.$route['url'])); 
17
+        $this->request = new RequestHandler($route['protocol'], new Uri($this->host.$route['url']));  
18
+        $this->serverRequest = (new Factory())->createServerRequest($route['protocol'], new Uri($this->host.$route['url'])); 
19 19
 
20
-        $middlewares = (is_array($route['middlewares'])) ? $route['middlewares'] : [ $route['middlewares'] ];
20
+        $middlewares = (is_array($route['middlewares'])) ? $route['middlewares'] : [$route['middlewares']];
21 21
 
22
-        foreach($middlewares as $middleware){
23
-            if(is_null($middleware)){
22
+        foreach ($middlewares as $middleware) {
23
+            if (is_null($middleware)) {
24 24
                 continue;
25 25
             }
26 26
 
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 
39 39
     protected function middlewareExists(string $m)
40 40
     {
41
-        if(class_exists(str_replace('::class','',$m))){
42
-            $m = str_replace('::class','',$m);
41
+        if (class_exists(str_replace('::class', '', $m))) {
42
+            $m = str_replace('::class', '', $m);
43 43
             return new $m();
44 44
         }
45 45
 
46
-        if(array_key_exists($m,$this->middlewares)){
46
+        if (array_key_exists($m, $this->middlewares)) {
47 47
             return new $this->middlewares[$m]();
48 48
         }
49 49
 
Please login to merge, or discard this patch.
examples/Routes/default.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@
 block discarded – undo
5 5
 
6 6
 
7 7
 /* Filter example */
8
-Router::get('/my-account',function(array $data){
8
+Router::get('/my-account', function(array $data) {
9 9
     echo '<pre>';
10 10
     var_dump($data);
11 11
     echo 'Ok';
12
-})->middleware(['\Example\Middleware\Auth::class','Lasted']);
12
+})->middleware(['\Example\Middleware\Auth::class', 'Lasted']);
13 13
 
14 14
 /* Returning parameters passed via URL in anonymous functions 
15 15
 Router::get('/{parameter}/{otherparameter}', function($parameter, $otherparameter){
Please login to merge, or discard this patch.
examples/Middleware/Auth.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 use Psr\Http\Message\ResponseInterface;
7 7
 use Psr\Http\Server\RequestHandlerInterface;
8 8
 
9
-class Auth extends Middleware{
9
+class Auth extends Middleware {
10 10
 
11 11
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
12 12
     {
13
-        if(!array_key_exists('user',$_SESSION)){
13
+        if (!array_key_exists('user', $_SESSION)) {
14 14
             $this->error = 'The user must be logged in to the system';
15 15
         }
16 16
 
Please login to merge, or discard this patch.
examples/Middleware/Lasted.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 use Psr\Http\Message\ResponseInterface;
8 8
 use Psr\Http\Server\RequestHandlerInterface;
9 9
 
10
-class Lasted extends Middleware{
10
+class Lasted extends Middleware {
11 11
 
12 12
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
13 13
     {
14
-        if(!isset($this->error)){
14
+        if (!isset($this->error)) {
15 15
             throw new Exception("Access not belonged: {$this->error}");
16 16
         }
17 17
 
Please login to merge, or discard this patch.