open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Manager/RedirectionManager.php

Summary

Maintainability
A
1 hr
Test Coverage

Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $redirectionClass,
        ContextBackOfficeInterface $contextManager,
        DocumentManager $documentManager,
        EventDispatcherInterface $eventDispatcher,
        SiteRepositoryInterface $siteRepository,
Severity: Major
Found in Backoffice/Manager/RedirectionManager.php - About 50 mins to fix

Function generateRedirectionForNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateRedirectionForNode(NodeInterface $node)
    {
        $siteId = $node->getSiteId();

        $this->deleteRedirection(
Severity: Minor
Found in Backoffice/Manager/RedirectionManager.php - About 25 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

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

use OpenOrchestra\ModelInterface\Model\RedirectionInterface;

Call to method findOneBySiteId from undeclared class \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open

        $site = $this->siteRepository->findOneBySiteId($this->contextManager->getSiteId());
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Required argument follows optional
Open

    protected function completeRoutePattern($parentId = null, $suffix = null, $language)

Call to method getParentId from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

                        $node->getLanguage()
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $documentManager has undeclared type \Doctrine\ODM\MongoDB\DocumentManager
Open

    public function __construct(

Call to method remove from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open

            $this->documentManager->remove($redirection);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Comment declares @param $siteRepository multiple times
Open

    public function __construct(

Call to method flush from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open

                $this->documentManager->flush($redirection);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getNodeId from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        $nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method __construct from undeclared class \OpenOrchestra\ModelInterface\Event\RedirectionEvent
Open

                $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Reference to constant REDIRECTION_DELETE from undeclared class \OpenOrchestra\ModelInterface\RedirectionEvents
Open

            $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function generateRedirectionForNode(NodeInterface $node)

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

use OpenOrchestra\ModelInterface\Model\SiteAliasInterface;

Doc-block of $siteRepository in __construct contains phpdoc param type \OpenOrchestra\ModelInterface\Repository\RedirectionRepositoryInterface which is incompatible with the param type \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface declared in the signature
Open

     * @param RedirectionRepositoryInterface $siteRepository

Call to method persist from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open

                $this->documentManager->persist($redirection);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method flush from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open

            $this->documentManager->flush($redirection);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

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

        $nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getSiteId from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        $siteId = $node->getSiteId();
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            $routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getNodeId from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            $node->getNodeId(),
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getRoutePattern from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            $routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getNodeId from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

                        $node->getNodeId(),
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $siteRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open

    public function __construct(

Reference to constant REDIRECTION_CREATE from undeclared class \OpenOrchestra\ModelInterface\RedirectionEvents
Open

                $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method findByNode from undeclared class \OpenOrchestra\ModelInterface\Repository\RedirectionRepositoryInterface
Open

        $redirections = $this->redirectionRepository->findByNode($nodeId, $language, $siteId);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $eventDispatcher has undeclared type \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open

    public function __construct(

Call to method dispatch from undeclared class \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open

                $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        $nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $redirectionRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\RedirectionRepositoryInterface
Open

    public function __construct(

Call to method __construct from undeclared class \OpenOrchestra\ModelInterface\Event\RedirectionEvent
Open

            $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

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

        if ($parent instanceof NodeInterface) {
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getRoutePattern from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Parameter $nodeRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open

    public function __construct(

Call to method dispatch from undeclared class \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open

            $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

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

        $parent = $this->nodeRepository->findOnePublished($parentId, $language, $siteId);
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

Call to method getLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

            $node->getLanguage(),
Severity: Critical
Found in Backoffice/Manager/RedirectionManager.php by phan

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

        RedirectionRepositoryInterface $redirectionRepository

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 $redirectionRepository. Keep variable name length under 20.
Open

    protected $redirectionRepository;

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

There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found 0 spaces
Open

    ){

Line exceeds 120 characters; contains 148 characters
Open

                $oldRoutePattern = $this->completeRoutePattern($otherNode->getParentId(), $otherNode->getRoutePattern(), $otherNode->getLanguage());

Line exceeds 120 characters; contains 150 characters
Open

            return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));

Line exceeds 120 characters; contains 121 characters
Open

                $redirection->setRoutePattern(preg_replace('#///|//#', '/', '/' . $alias->getPrefix() . '/' . $pattern));

Line exceeds 120 characters; contains 138 characters
Open

            $routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));

Line exceeds 120 characters; contains 124 characters
Open

                $this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));

Arguments with default values must be at the end of the argument list
Open

    protected function completeRoutePattern($parentId = null, $suffix = null, $language)

Multi-line function call not indented correctly; expected 20 spaces but found 24
Open

                        );

Multi-line function call not indented correctly; expected 8 spaces but found 12
Open

            );

There are no issues that match your filters.

Category
Status