open-orchestra/open-orchestra-cms-bundle

View on GitHub
GroupBundle/Form/DataTransformer/GroupListToArrayTransformer.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    public function reverseTransform($groups)
    {
        $value = new ArrayCollection();
        if (is_array($groups) && array_key_exists('groups_collection', $groups)) {
            $groups = $groups['groups_collection'];
Severity: Minor
Found in GroupBundle/Form/DataTransformer/GroupListToArrayTransformer.php - About 1 hr 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 $groups has undeclared type \Doctrine\Common\Collections\ArrayCollection
Open

    public function transform($groups)

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

        if ($groups instanceof Collection) {

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

                        $value->add($group);

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

        $value = new ArrayCollection();

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

class GroupListToArrayTransformer implements DataTransformerInterface

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

    public function reverseTransform($groups)

Call to method getId from undeclared class \OpenOrchestra\Backoffice\Context\SiteInterface
Open

            $this->availableSiteIds[] = $site->getId();

Call to undeclared method \OpenOrchestra\GroupBundle\Repository\GroupRepository::find
Open

                    $group = $this->groupRepository->find($groupId);

Expected 1 space after FOREACH keyword; 0 found
Open

            foreach($groups as $group) {

There are no issues that match your filters.

Category
Status