src/Security/Voter/UserVoter.php line 12
<?phpdeclare(strict_types=1);namespace App\Security\Voter;use App\Entity\User\User;use App\Helper\UserHelper;use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;use Symfony\Component\Security\Core\Authorization\Voter\Voter;class UserVoter extends Voter{const CHANGE_ROLE = 'CHANGE_ROLE';protected function supports(string $attribute, mixed $subject): bool{if (!\in_array($attribute, [self::CHANGE_ROLE])) {return false;}if (!$subject instanceof User) {return false;}return true;}protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool{$user = $token->getUser();if (!$user instanceof User) {return false;}return match ($attribute) {self::CHANGE_ROLE => UserHelper::isAdmin($user),default => throw new \LogicException('This code should not be reached!'),};}}