src/Invoice/Security/InvoiceRepeatRule/InvoiceRepeatRuleVoter.php line 27
<?phpdeclare(strict_types=1);/*** Copyright (c) 2020 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2020 TECLA Consulting Group oü*/namespace App\Invoice\Security\InvoiceRepeatRule;use App\Invoice\Model\InvoiceRepeatRuleInterface;use LogicException;use Symfony\Component\DependencyInjection\ServiceLocator;use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;use Symfony\Component\Security\Core\Authorization\Voter\Voter;final class InvoiceRepeatRuleVoter extends Voter{private ServiceLocator $criteria;public function __construct(ServiceLocator $criteria){$this->criteria = $criteria;}protected function supports(string $attribute, $subject): bool{return $this->criteria->has($attribute) && (null === $subject || true === $subject instanceof InvoiceRepeatRuleInterface);}protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool{/** @var ?InvoiceRepeatRuleInterface $invoiceRepeatRule */$invoiceRepeatRule = $subject;/** @var CriterionInterface $criterion */$criterion = ($this->criteria)($attribute);if ($criterion) {return $criterion->handle($invoiceRepeatRule);}throw new LogicException('This code should not be reached!');}}