open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Security/Authorization/Voter/AbstractVoter.php

Summary

Maintainability
A
25 mins
Test Coverage

Function hasRole has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function hasRole(TokenInterface $token, $role)
    {
        $roles = $token->getRoles();
        foreach ($roles as $checkRole) {
            if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||
Severity: Minor
Found in Backoffice/Security/Authorization/Voter/AbstractVoter.php - About 25 mins to fix

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

    protected function isSuperAdmin(TokenInterface $token)

Parameter $token has undeclared type \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open

    protected function hasRole(TokenInterface $token, $role)

Checking instanceof against undeclared class \Symfony\Component\Security\Core\Role\RoleInterface
Open

            if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||

Call to method getRole from undeclared class \Symfony\Component\Security\Core\Role\RoleInterface
Open

            if (($checkRole instanceof RoleInterface && $role === $checkRole->getRole()) ||

Class extends undeclared class \Symfony\Component\Security\Core\Authorization\Voter\Voter
Open

abstract class AbstractVoter extends Voter

Call to method decide from undeclared class \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open

        return $this->decisionManager->decide($token, array(ContributionRoleInterface::PLATFORM_ADMIN));

Parameter $decisionManager has undeclared type \Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
Open

    public function __construct(AccessDecisionManagerInterface $decisionManager)

Call to method getRoles from undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open

        $roles = $token->getRoles();

Opening brace should be on a new line
Open

    protected function supportClasses($subject, array $classes) {

There are no issues that match your filters.

Category
Status