Backoffice/Security/Authorization/Voter/AbstractVoter.php
Function hasRole
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function hasRole(TokenInterface $token, $role)
{
$roles = $token->getRoles();
foreach ($roles as $checkRole) {
if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Parameter $token
has undeclared type \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
Open
protected function isSuperAdmin(TokenInterface $token)
- Create a ticketCreate a ticket
- Exclude checks
Parameter $token
has undeclared type \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
Open
protected function hasRole(TokenInterface $token, $role)
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \Symfony\Component\Security\Core\Role\RoleInterface
Open
Open
if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||
- Create a ticketCreate a ticket
- Exclude checks
Call to method getRole
from undeclared class \Symfony\Component\Security\Core\Role\RoleInterface
Open
Open
if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \Symfony\Component\Security\Core\Authorization\Voter\Voter
Open
Open
abstract class AbstractVoter extends Voter
- Create a ticketCreate a ticket
- Exclude checks
Call to method decide
from undeclared class \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open
Open
return $this->decisionManager->decide($token, array(ContributionRoleInterface::PLATFORM_ADMIN));
- Create a ticketCreate a ticket
- Exclude checks
Parameter $decisionManager
has undeclared type \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open
Open
public function __construct(AccessDecisionManagerInterface $decisionManager)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getRoles
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
Open
$roles = $token->getRoles();
- Create a ticketCreate a ticket
- Exclude checks
Opening brace should be on a new line Open
Open
protected function supportClasses($subject, array $classes) {
- Create a ticketCreate a ticket
- Exclude checks