open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/EventSubscriber/UpdateNodeSiteAliasSubscriber.php

Summary

Maintainability
A
35 mins
Test Coverage

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

    public function updateNodeOnSiteAliasUpdate(SiteEvent $event)
    {
        $languages = array();
        foreach ($event->getOldAliases() as $alias) {
            $languages[] = $alias->getLanguage();
Severity: Minor
Found in Backoffice/EventSubscriber/UpdateNodeSiteAliasSubscriber.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 $nodeRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open

    public function __construct(

Call to method getOldAliases from undeclared class \OpenOrchestra\ModelInterface\Event\SiteEvent
Open

        foreach ($event->getOldAliases() as $alias) {

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

            $this->objectManager->flush();

Call to method getSite from undeclared class \OpenOrchestra\ModelInterface\Event\SiteEvent
Open

            $nodes = $this->nodeRepository->findLastVersionByLanguage($event->getSite()->getSiteId(), $languageReference);

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

    public function __construct(

Parameter $event has undeclared type \OpenOrchestra\ModelInterface\Event\SiteEvent
Open

    public function updateNodeOnSiteAliasUpdate(SiteEvent $event)

Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open

class UpdateNodeSiteAliasSubscriber implements EventSubscriberInterface

Call to method getSite from undeclared class \OpenOrchestra\ModelInterface\Event\SiteEvent
Open

        $languages = array_diff($event->getSite()->getLanguages(), $languages);

Call to method findLastVersionByLanguage from undeclared class \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open

            $nodes = $this->nodeRepository->findLastVersionByLanguage($event->getSite()->getSiteId(), $languageReference);

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

                    $this->objectManager->persist($this->nodeManager->createNewLanguageNode($node, $language));

Reference to constant SITE_UPDATE from undeclared class \OpenOrchestra\ModelInterface\SiteEvents
Open

            SiteEvents::SITE_UPDATE => 'updateNodeOnSiteAliasUpdate',

Line exceeds 120 characters; contains 122 characters
Open

            $nodes = $this->nodeRepository->findLastVersionByLanguage($event->getSite()->getSiteId(), $languageReference);

There are no issues that match your filters.

Category
Status