open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/EventListener/UpdateStatusableElementPublished.php

Summary

Maintainability
A
1 hr
Test Coverage

Function updateStatus has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function updateStatus(EventStatusableInterface $event)
    {
        $statusableElement = $event->getStatusableElement();

        if (true === $statusableElement->getStatus()->isPublishedState() &&
Severity: Minor
Found in Backoffice/EventListener/UpdateStatusableElementPublished.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 $event has undeclared type \OpenOrchestra\ModelInterface\Event\EventTrait\EventStatusableInterface
Open

    public function updateStatus(EventStatusableInterface $event)

Call to method findOneByAutoUnpublishTo from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

                $statusUnPublish = $this->statusRepository->findOneByAutoUnpublishTo();

Parameter $statusRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

    public function __construct(

Call to method getStatusableElement from undeclared class \OpenOrchestra\ModelInterface\Event\EventTrait\EventStatusableInterface
Open

        $statusableElement = $event->getStatusableElement();

Call to method flush from undeclared class \Doctrine\Common\Persistence\ObjectManager
Open

                $this->objectManager->flush();

Parameter $repository has undeclared type \OpenOrchestra\ModelInterface\Repository\StatusableRepositoryInterface
Open

    public function __construct(

Parameter $objectManager has undeclared type \Doctrine\Common\Persistence\ObjectManager
Open

    public function __construct(

Possibly zero references to use statement for classlike/namespace StatusableInterface (\OpenOrchestra\ModelInterface\Model\StatusableInterface)
Open

use OpenOrchestra\ModelInterface\Model\StatusableInterface;

Call to method findPublished from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusableRepositoryInterface
Open

            $elementsPublished = $this->repository->findPublished($statusableElement);

Blank line found at start of control structure
Open

            if (!empty($elementsPublished)) {

There are no issues that match your filters.

Category
Status