Passed
Push — main ( 1e821c...d0f83f )
by Roberto
02:00
created
src/Authenticator/RBAC/UserInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
     public function hasPermission(PermissionInterface $permission) : bool;
21 21
 
22 22
 
23
-     /**
24
-     * Retrieve the permissions associated with the user's roles.
25
-     *
26
-     * @return array An array of permissions associated with the user's roles.
27
-     */
23
+        /**
24
+         * Retrieve the permissions associated with the user's roles.
25
+         *
26
+         * @return array An array of permissions associated with the user's roles.
27
+         */
28 28
     public function getPermissions() : array;
29 29
 
30 30
 
Please login to merge, or discard this patch.
src/Middleware/RBACMiddleware.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
         $this->rbac_class = $middlewareParams["rbac_class"] ?? throw new \Exception("You have to define a RBAC class");
21 21
 
22 22
         $rbac_interfaces = class_implements($this->rbac_class);
23
-        if(! in_array(\Lepton\Authenticator\RBAC\RBACInterface::class, $rbac_interfaces)) {
23
+        if (!in_array(\Lepton\Authenticator\RBAC\RBACInterface::class, $rbac_interfaces)) {
24 24
                 throw new \Exception("RBAC class has to implement \Lepton\Authenticator\RBAC\RBACInterface");
25 25
         }
26 26
 
27 27
         $this->user_class = $middlewareParams["user_class"] ?? throw new \Exception("You have to define a User class");
28 28
 
29 29
         $user_interfaces = class_implements($this->user_class);
30
-        if(! in_array(\Lepton\Authenticator\RBAC\UserInterface::class, $user_interfaces)) {
30
+        if (!in_array(\Lepton\Authenticator\RBAC\UserInterface::class, $user_interfaces)) {
31 31
                 throw new \Exception("User class has to implement \Lepton\Authenticator\RBAC\UserInterface");
32 32
         }
33 33
 
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
     protected function checkPermissions(string $modifier, mixed ...$params): bool
39 39
     {
40 40
 
41
-        if($modifier == LoginRequired::class) {
41
+        if ($modifier == LoginRequired::class) {
42 42
 
43 43
             $level = isset($params[0]) ? $params[0] : 1;
44 44
             $authenticator = new \Lepton\Authenticator\UserAuthenticator();
45 45
             $loggedIn = $authenticator->isLoggedIn();
46
-            if(! $loggedIn) {
46
+            if (!$loggedIn) {
47 47
                 return false;
48 48
             }
49 49
             $user = $authenticator->getLoggedUser();
50 50
             $num_privileges = $user->privileges->and(livello__gte: $level)->count();
51 51
             return ($num_privileges > 0);
52
-        } elseif($modifier == PermissionRequired::class){
52
+        } elseif ($modifier == PermissionRequired::class) {
53 53
             $user = (new UserAuthenticator)->getLoggedUser();
54 54
             die(print_r($params));
55 55
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             $user = $authenticator->getLoggedUser();
50 50
             $num_privileges = $user->privileges->and(livello__gte: $level)->count();
51 51
             return ($num_privileges > 0);
52
-        } elseif($modifier == PermissionRequired::class){
52
+        } elseif($modifier == PermissionRequired::class) {
53 53
             $user = (new UserAuthenticator)->getLoggedUser();
54 54
             die(print_r($params));
55 55
         }
Please login to merge, or discard this patch.
src/Http/Response/JSONResponse.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 JSONResponse extends SuccessResponse
5
+    class JSONResponse 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
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
         parent::__construct(headers: ["Content-Type" => "application/json"]);
13 13
     }
14 14
 
15
-    public function sendBody(){
15
+    public function sendBody() {
16 16
         echo json_encode($this->array);
17 17
     }
18 18
 
Please login to merge, or discard this patch.