Completed
Push — master ( 893f23...6ffa07 )
by Olivier
01:11 queued 01:01
created
lib/VoterProvider.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@
 block discarded – undo
13 13
 
14 14
 interface VoterProvider
15 15
 {
16
-    /**
17
-     * Returns a voter for a permission.
18
-     *
19
-     * The dispatcher should fail if the function returns `null`, but a chain of voter providers
20
-     * could invoke the next voter provider.
21
-     *
22
-     * @throws VoterNotFound
23
-     */
24
-    public function getVoterForPermission(string $permission): ?Voter;
16
+	/**
17
+	 * Returns a voter for a permission.
18
+	 *
19
+	 * The dispatcher should fail if the function returns `null`, but a chain of voter providers
20
+	 * could invoke the next voter provider.
21
+	 *
22
+	 * @throws VoterNotFound
23
+	 */
24
+	public function getVoterForPermission(string $permission): ?Voter;
25 25
 }
Please login to merge, or discard this patch.
lib/VoterNotFound.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
  */
20 20
 class VoterNotFound extends LogicException implements Exception
21 21
 {
22
-    public function __construct(
23
-        public string $permission,
24
-        ?Throwable $previous = null
25
-    ) {
26
-        parent::__construct("Voter not found for permission: $permission", 0, $previous);
27
-    }
22
+	public function __construct(
23
+		public string $permission,
24
+		?Throwable $previous = null
25
+	) {
26
+		parent::__construct("Voter not found for permission: $permission", 0, $previous);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
lib/Voter.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
  */
17 17
 interface Voter
18 18
 {
19
-    /**
20
-     * Returns `true` when permission is granted, ending the voting process positively.
21
-     */
22
-    public function isGranted(object $message, Context $context): bool;
19
+	/**
20
+	 * Returns `true` when permission is granted, ending the voting process positively.
21
+	 */
22
+	public function isGranted(object $message, Context $context): bool;
23 23
 }
Please login to merge, or discard this patch.
lib/VoterWithPermissions.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -16,30 +16,30 @@
 block discarded – undo
16 16
  */
17 17
 final class VoterWithPermissions implements Voter
18 18
 {
19
-    /**
20
-     * @param array<class-string, string[]> $permissionsByMessage
21
-     *     Where _key_ is a command class and _value_ the permissions for that message.
22
-     */
23
-    public function __construct(
24
-        private VoterProvider $voters,
25
-        private array $permissionsByMessage,
26
-    ) {
27
-    }
19
+	/**
20
+	 * @param array<class-string, string[]> $permissionsByMessage
21
+	 *     Where _key_ is a command class and _value_ the permissions for that message.
22
+	 */
23
+	public function __construct(
24
+		private VoterProvider $voters,
25
+		private array $permissionsByMessage,
26
+	) {
27
+	}
28 28
 
29
-    public function isGranted(object $message, Context $context): bool
30
-    {
31
-        $permissions = $this->permissionsByMessage[$message::class] ?? null;
29
+	public function isGranted(object $message, Context $context): bool
30
+	{
31
+		$permissions = $this->permissionsByMessage[$message::class] ?? null;
32 32
 
33
-        if (!$permissions) {
34
-            return true;
35
-        }
33
+		if (!$permissions) {
34
+			return true;
35
+		}
36 36
 
37
-        foreach ($permissions as $permission) {
38
-            if ($this->voters->getVoterForPermission($permission)?->isGranted($message, $context)) {
39
-                return true;
40
-            }
41
-        }
37
+		foreach ($permissions as $permission) {
38
+			if ($this->voters->getVoterForPermission($permission)?->isGranted($message, $context)) {
39
+				return true;
40
+			}
41
+		}
42 42
 
43
-        return false;
44
-    }
43
+		return false;
44
+	}
45 45
 }
Please login to merge, or discard this patch.