open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
35 mins
Test Coverage

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

    public function validate($value, Constraint $constraint)
    {
        if($value instanceof ContentTypeInterface) {
            $fields = $value->getFields();
            foreach ($fields as $key => $field) {
Severity: Minor
Found in Backoffice/Validator/Constraints/ContentTypeFieldValidator.php - About 35 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 $constraint has undeclared type \Symfony\Component\Validator\Constraint
Open

    public function validate($value, Constraint $constraint)

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

        if($value instanceof ContentTypeInterface) {

Call to method getFields from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

            $fields = $value->getFields();

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

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

Reference to instance property message from undeclared class \Symfony\Component\Validator\Constraint
Open

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

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

class ContentTypeFieldValidator extends ConstraintValidator

Call to method getFieldId from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

                if ($field instanceof FieldTypeInterface && in_array($field->getFieldId(), $this->disallowedFieldNames)) {

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

                if ($field instanceof FieldTypeInterface && in_array($field->getFieldId(), $this->disallowedFieldNames)) {

Line exceeds 120 characters; contains 122 characters
Open

                if ($field instanceof FieldTypeInterface && in_array($field->getFieldId(), $this->disallowedFieldNames)) {

Expected 1 space after IF keyword; 0 found
Open

        if($value instanceof ContentTypeInterface) {

There are no issues that match your filters.

Category
Status