From ab97482ae62c104a23dced2f0c5db48e732cb0e0 Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 10 May 2025 12:31:57 +0200 Subject: [PATCH] Improve snip voter readability --- src/Security/Voter/SnipVoter.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Security/Voter/SnipVoter.php b/src/Security/Voter/SnipVoter.php index d28649d..012d158 100644 --- a/src/Security/Voter/SnipVoter.php +++ b/src/Security/Voter/SnipVoter.php @@ -24,16 +24,17 @@ class SnipVoter extends Voter { /** @var Snip $subject */ + $user = $token->getUser(); + if (!$user instanceof UserInterface) { + return false; + } + switch ($attribute) { case self::VIEW: if ($subject->isPublic()) { return true; } case self::EDIT: - $user = $token->getUser(); - if (!$user instanceof UserInterface) { - return false; - } if ($subject->getCreatedBy() === $user) { return true; }