Passed
Push — main ( 180138...a48f4d )
by Roberto
02:03 queued 13s
created
src/Core/Handler/StaticHandler.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@
 block discarded – undo
45 45
             }
46 46
             return new MatchFile(filePath: $filePath, contentType: $contentType);
47 47
         } else {
48
-          return new Match404();
48
+            return new Match404();
49 49
         }
50 50
     }
51 51
 
52 52
     public function handle($match): FileResponse|NotFoundResponse{
53
-      if($match instanceof Match404){
53
+        if($match instanceof Match404){
54 54
         return new NotFoundResponse();
55
-      }
56
-      return new FileResponse($match->filePath, $match->contentType);
55
+        }
56
+        return new FileResponse($match->filePath, $match->contentType);
57 57
     }
58 58
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
         // Get the requested file path
14 14
         $url = preg_replace("/^\/".Application::getAppConfig()->base_url."\//", "/", $this->request->url);
15
-        $filePath = Application::$documentRoot. Application::getAppConfig()->static_files_dir . $url;
15
+        $filePath = Application::$documentRoot.Application::getAppConfig()->static_files_dir.$url;
16 16
 
17 17
         // Check if the file exists
18 18
         if (file_exists($filePath)) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     }
51 51
 
52 52
     public function handle($match): FileResponse|NotFoundResponse{
53
-      if($match instanceof Match404){
53
+      if ($match instanceof Match404) {
54 54
         return new NotFoundResponse();
55 55
       }
56 56
       return new FileResponse($match->filePath, $match->contentType);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     }
51 51
 
52 52
     public function handle($match): FileResponse|NotFoundResponse{
53
-      if($match instanceof Match404){
53
+      if($match instanceof Match404) {
54 54
         return new NotFoundResponse();
55 55
       }
56 56
       return new FileResponse($match->filePath, $match->contentType);
Please login to merge, or discard this patch.
src/Core/Handler/BaseHandler.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -56,13 +56,13 @@
 block discarded – undo
56 56
         if($matcher instanceof MatchRoute) {
57 57
 
58 58
             foreach($this->middlewares as $middleware => $args){
59
-              $middlewareInstance = new $middleware();
60
-              $middlewareInstance->addMatcher($matcher);
61
-              $middlewareInstance->setRequest($this->request);
62
-              $middlewareResult = $middlewareInstance(...$args);
63
-              if($middlewareResult instanceof HttpResponse){
59
+                $middlewareInstance = new $middleware();
60
+                $middlewareInstance->addMatcher($matcher);
61
+                $middlewareInstance->setRequest($this->request);
62
+                $middlewareResult = $middlewareInstance(...$args);
63
+                if($middlewareResult instanceof HttpResponse){
64 64
                 return $middlewareResult;
65
-              }
65
+                }
66 66
             }
67 67
 
68 68
             $controller = new $matcher->controller();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 // Check if callback is a controller method
33 33
                 $controller = $callback[0];
34 34
                 $method = $callback[1];
35
-                if (! method_exists($controller, $method)) {
35
+                if (!method_exists($controller, $method)) {
36 36
                     throw new Exceptions\ControllerNotFoundException("Invalid Controller and/or method in routes.php");
37 37
                 }
38 38
                 return new MatchRoute(controller: $controller, method: $method, parameters: $parameters);
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
      */
50 50
     protected function handle(BaseMatch $matcher): HttpResponse
51 51
     {
52
-        if($matcher instanceof Match404) {
52
+        if ($matcher instanceof Match404) {
53 53
             return new NotFoundResponse();
54 54
         }
55 55
 
56
-        if($matcher instanceof MatchRoute) {
56
+        if ($matcher instanceof MatchRoute) {
57 57
 
58
-            foreach($this->middlewares as $middleware => $args){
58
+            foreach ($this->middlewares as $middleware => $args) {
59 59
               $middlewareInstance = new $middleware();
60 60
               $middlewareInstance->addMatcher($matcher);
61 61
               $middlewareInstance->setRequest($this->request);
62 62
               $middlewareResult = $middlewareInstance(...$args);
63
-              if($middlewareResult instanceof HttpResponse){
63
+              if ($middlewareResult instanceof HttpResponse) {
64 64
                 return $middlewareResult;
65 65
               }
66 66
             }
67 67
 
68 68
             $controller = new $matcher->controller();
69
-            $method =  $matcher->method;
69
+            $method = $matcher->method;
70 70
             return $controller->$method();
71 71
         }
72 72
         throw new \Exception("Wrong matcher!");
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
               $middlewareInstance->addMatcher($matcher);
61 61
               $middlewareInstance->setRequest($this->request);
62 62
               $middlewareResult = $middlewareInstance(...$args);
63
-              if($middlewareResult instanceof HttpResponse){
63
+              if($middlewareResult instanceof HttpResponse) {
64 64
                 return $middlewareResult;
65 65
               }
66 66
             }
Please login to merge, or discard this patch.
src/Core/Handler/AbstractHandler.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     protected $middlewares = array();
16 16
 
17 17
     public function __construct($request){
18
-      $this->request = $request;
18
+        $this->request = $request;
19 19
     }
20 20
 
21 21
     public function addMiddlewares($middlewares) {
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
 
25 25
 
26 26
     public function getResponse() : HttpResponse{
27
-      $matcher = $this->resolveRequest();
28
-      return $this->handle($matcher);
27
+        $matcher = $this->resolveRequest();
28
+        return $this->handle($matcher);
29 29
 
30 30
     }
31 31
 
32 32
 
33 33
 
34
-  }
34
+    }
35 35
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     protected Request $request;
15 15
     protected $middlewares = array();
16 16
 
17
-    public function __construct($request){
17
+    public function __construct($request) {
18 18
       $this->request = $request;
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/Core/Application.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
      * Returns the appropriate handler for the pending request
62 62
      *
63 63
      * @return AbstractHandler $handler
64
-    */
64
+     */
65 65
     public static function getHandler(): AbstractHandler
66 66
     {
67 67
         $regex = '/\.(?:'.implode('|', static::$_config->static_files_extensions).')$/';
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function run()
31 31
     {
32
-        if(! static::$_config) {
32
+        if (!static::$_config) {
33 33
             throw new \Exception("No config loaded!");
34 34
         }
35 35
 
36 36
         session_start();
37 37
 
38
-        if(static::$_dbconfig->use_db) {
38
+        if (static::$_dbconfig->use_db) {
39 39
             static::$_db = new Database(
40 40
                 static::$_dbconfig->host,
41 41
                 static::$_dbconfig->user,
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $response = $handler->getResponse();
50 50
         $response->send();
51 51
 
52
-        if(static::$_dbconfig->use_db) {
52
+        if (static::$_dbconfig->use_db) {
53 53
             static::$_db->close();
54 54
         }
55 55
 
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
 
83 83
     public static function loadConfig(\stdClass $config)
84 84
     {
85
-        if(property_exists($config, "app")) {
85
+        if (property_exists($config, "app")) {
86 86
             static::$_config = $config->app;
87 87
         } else {
88 88
             throw new \Exception("No app configuration!");
89 89
         }
90 90
 
91
-        if(property_exists($config, "routes")) {
91
+        if (property_exists($config, "routes")) {
92 92
             static::$routes = $config->routes;
93 93
         } else {
94 94
             throw new \Exception("No routes configuration!");
95 95
         }
96 96
 
97 97
 
98
-        if(property_exists($config, "database")) {
98
+        if (property_exists($config, "database")) {
99 99
             static::$_dbconfig = $config->database;
100 100
         } else {
101 101
             throw new \Exception("No database configuration!");
102 102
         }
103 103
 
104 104
 
105
-        if(property_exists($config, "auth")) {
105
+        if (property_exists($config, "auth")) {
106 106
             static::$_auth = $config->auth;
107 107
         } else {
108 108
             throw new \Exception("No authentication configuration!");
109 109
         }
110 110
 
111
-        if(property_exists($config, "email")) {
111
+        if (property_exists($config, "email")) {
112 112
             static::$_email = $config->email;
113 113
         } else {
114 114
             throw new \Exception("No email configuration!");
Please login to merge, or discard this patch.
src/Http/Response/SuccessResponse.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Lepton\Http\Response;
4 4
 
5
- class SuccessResponse extends HttpResponse
5
+    class SuccessResponse extends HttpResponse
6 6
 {
7 7
 
8 8
     public function __construct(
Please login to merge, or discard this patch.
src/Http/Response/FileResponse.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Lepton\Http\Response;
4 4
 
5
- class FileResponse extends SuccessResponse
5
+    class FileResponse extends SuccessResponse
6 6
 {
7 7
 
8 8
     public function __construct(
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         parent::__construct(headers: ["Content-Type" => $contentType]);
15 15
     }
16 16
 
17
-    public function sendBody(){
17
+    public function sendBody() {
18 18
         readfile($this->filePath);
19 19
     }
20 20
 
Please login to merge, or discard this patch.
src/Http/Response/RedirectResponse.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public $headers;
10 10
     public $body;
11 11
 
12
-    public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null )
12
+    public function __construct($url, $htmx = false, $parse = true, $code = 302, $redirect_after = null)
13 13
     {
14 14
         if ($this->isLocalUrl($url) && $parse) {
15 15
             $parsedUrl = Application::getDir()."/".$url;
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
         if ($htmx) {
20 20
             $headers = ["HX-Redirect" => $parsedUrl];
21 21
         } else {
22
-            $headers = [ "Location" => $parsedUrl ];
22
+            $headers = ["Location" => $parsedUrl];
23 23
         }
24
-        if(isset($redirect_after)){
24
+        if (isset($redirect_after)) {
25 25
             $_SESSION["redirect_url"] = $redirect_after;
26 26
 
27 27
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         } else {
22 22
             $headers = [ "Location" => $parsedUrl ];
23 23
         }
24
-        if(isset($redirect_after)){
24
+        if(isset($redirect_after)) {
25 25
             $_SESSION["redirect_url"] = $redirect_after;
26 26
 
27 27
         }
Please login to merge, or discard this patch.
src/Http/Response/HttpResponse.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
     }
14 14
 
15 15
 
16
-    public function sendHeaders(){
16
+    public function sendHeaders() {
17 17
         foreach ($this->headers as $key => $value) {
18 18
             header("$key: $value");
19 19
         }
20 20
     }
21 21
 
22
-    public function sendBody(){
22
+    public function sendBody() {
23 23
         echo $this->body;
24 24
     }
25 25
 
Please login to merge, or discard this patch.
src/Http/Response/NotFoundResponse.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Lepton\Http\Response;
4 4
 
5
- class NotFoundResponse extends HttpResponse
5
+    class NotFoundResponse extends HttpResponse
6 6
 {
7 7
 
8 8
     public function __construct(
Please login to merge, or discard this patch.