open-orchestra/open-orchestra-cms-bundle

View on GitHub
WorkflowAdminBundle/Form/DataTransformer/GroupWorkflowProfileCollectionTransformer.php

Summary

Maintainability
B
4 hrs
Test Coverage

Function reverseTransform has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    public function reverseTransform($value)
    {
        $result = new ArrayCollection();
        if (is_array($value)) {
            foreach ($value as $key => $profiles) {

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

Function transform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function transform($value)
    {
        $result = array();
        $workflowProfiles = $this->workflowProfileRepository->findAll();
        $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();

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

Class implements undeclared interface \Symfony\Component\Form\DataTransformerInterface
Open

class GroupWorkflowProfileCollectionTransformer implements DataTransformerInterface

Parameter $value has undeclared type \Doctrine\Common\Collections\Collection
Open

    public function transform($value)

Call to method findAllNotDeletedInLastVersion from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface
Open

        $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();

Return type of reverseTransform() is undeclared type \Doctrine\Common\Collections\Collection
Open

    public function reverseTransform($value)

Call to method findAll from undeclared class \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open

        $workflowProfiles = $this->workflowProfileRepository->findAll();

Call to method __construct from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

        $result = new ArrayCollection();

Call to method set from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

                $result->set($key, $profileCollection);

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            $nodeTypeId = NodeInterface::ENTITY_TYPE;

Parameter $contentTypeRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface
Open

    public function __construct(

Parameter $workflowProfileRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open

    public function __construct(

Returning type \Doctrine\Common\Collections\ArrayCollection but reverseTransform() is declared to return \Doctrine\Common\Collections\Collection
Open

        return $result;

Checking instanceof against undeclared class \Doctrine\Common\Collections\Collection
Open

        if ($value instanceof Collection) {

Call to method find from undeclared class \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open

                            $document = $this->workflowProfileRepository->find($profileId);

Call to method __construct from undeclared class \OpenOrchestra\ModelBundle\Document\WorkflowProfileCollection
Open

                    $profileCollection = new WorkflowProfileCollection();

Call to method addProfile from undeclared class \OpenOrchestra\ModelBundle\Document\WorkflowProfileCollection
Open

                                $profileCollection->addProfile($document);

Avoid excessively long variable names like $settedWorkflowProfiles. Keep variable name length under 20.
Open

        $settedWorkflowProfiles = array();

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $workflowProfileRepository. Keep variable name length under 20.
Open

    protected $workflowProfileRepository;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $workflowProfileCollectionName. Keep variable name length under 20.
Open

            foreach ($value as $workflowProfileCollectionName => $workflowProfileCollection) {

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $contentTypeRepository. Keep variable name length under 20.
Open

    protected $contentTypeRepository;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $workflowProfileCollection. Keep variable name length under 20.
Open

            foreach ($value as $workflowProfileCollectionName => $workflowProfileCollection) {

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $contentTypeRepository. Keep variable name length under 20.
Open

        ContentTypeRepositoryInterface $contentTypeRepository,

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $workflowProfileRepository. Keep variable name length under 20.
Open

        WorkflowProfileRepositoryInterface $workflowProfileRepository,

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long class names like GroupWorkflowProfileCollectionTransformer. Keep class name length under 40.
Open

class GroupWorkflowProfileCollectionTransformer implements DataTransformerInterface
{
    protected $workflowProfileRepository;
    protected $contentTypeRepository;
    protected $contextManager;

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

Source https://phpmd.org/rules/naming.html#longclassname

Line exceeds 120 characters; contains 194 characters
Open

            $result[$nodeTypeId][$workflowProfile->getId()] = array_key_exists($nodeTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$nodeTypeId]);

Line exceeds 120 characters; contains 207 characters
Open

                $result[$contentTypeId][$workflowProfile->getId()] = array_key_exists($contentTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$contentTypeId]);

There are no issues that match your filters.

Category
Status