open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Validator/Constraints/UnremovableLanguageConditionValidator.php

Summary

Maintainability
A
45 mins
Test Coverage

Function validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate($value, Constraint $constraint)
    {
        if ($constraint instanceof UnremovableLanguageConditionInterface) {
            $languages = array();
            foreach ($value as $alias) {

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

Call to method getLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\SiteAliasInterface
Open

                    $languages[] = $alias->getLanguage();

Class extends undeclared class \Symfony\Component\Validator\ConstraintValidator
Open

class UnremovableLanguageConditionValidator extends ConstraintValidator

Reference to undeclared property \OpenOrchestra\Backoffice\Validator\Constraints\UnremovableLanguageConditionInterface->message
Open

                $this->context->buildViolation($constraint->message)

Parameter $constraint has undeclared type \Symfony\Component\Validator\Constraint
Open

    public function validate($value, Constraint $constraint)

string passed to foreach instead of array
Open

            foreach ($value as $alias) {

Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\SiteAliasInterface
Open

                if ($alias instanceof SiteAliasInterface) {

Reference to undeclared property \OpenOrchestra\Backoffice\Validator\Constraints\UnremovableLanguageConditionValidator->context
Open

                $this->context->buildViolation($constraint->message)

There must be one blank line after the last USE statement; 2 found;
Open

use Symfony\Component\Validator\ConstraintValidator;

There are no issues that match your filters.

Category
Status