Backoffice/Manager/RedirectionManager.php
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
$redirectionClass,
ContextBackOfficeInterface $contextManager,
DocumentManager $documentManager,
EventDispatcherInterface $eventDispatcher,
SiteRepositoryInterface $siteRepository,
- Create a ticketCreate a ticket
Function generateRedirectionForNode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
public function generateRedirectionForNode(NodeInterface $node)
{
$siteId = $node->getSiteId();
$this->deleteRedirection(
- Read upRead up
- Create a ticketCreate a ticket
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
Open
use OpenOrchestra\ModelInterface\Model\RedirectionInterface;
- Create a ticketCreate a ticket
- Exclude checks
Call to method findOneBySiteId
from undeclared class \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
Open
$site = $this->siteRepository->findOneBySiteId($this->contextManager->getSiteId());
- Create a ticketCreate a ticket
- Exclude checks
Required argument follows optional Open
Open
protected function completeRoutePattern($parentId = null, $suffix = null, $language)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getParentId
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$node->getLanguage()
- Create a ticketCreate a ticket
- Exclude checks
Parameter $documentManager
has undeclared type \Doctrine\ODM\MongoDB\DocumentManager
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method remove
from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open
Open
$this->documentManager->remove($redirection);
- Create a ticketCreate a ticket
- Exclude checks
Comment declares @param $siteRepository
multiple times Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method flush
from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open
Open
$this->documentManager->flush($redirection);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getNodeId
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\RedirectionEvent
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant REDIRECTION_DELETE
from undeclared class \OpenOrchestra\ModelInterface\RedirectionEvents
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Parameter $node
has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
public function generateRedirectionForNode(NodeInterface $node)
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace SiteAliasInterface
(\OpenOrchestra\ModelInterface\Model\SiteAliasInterface)
Open
Open
use OpenOrchestra\ModelInterface\Model\SiteAliasInterface;
- Create a ticketCreate a ticket
- Exclude checks
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
Open
* @param RedirectionRepositoryInterface $siteRepository
- Create a ticketCreate a ticket
- Exclude checks
Call to method persist
from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open
Open
$this->documentManager->persist($redirection);
- Create a ticketCreate a ticket
- Exclude checks
Call to method flush
from undeclared class \Doctrine\ODM\MongoDB\DocumentManager
Open
Open
$this->documentManager->flush($redirection);
- Create a ticketCreate a ticket
- Exclude checks
Call to method findPublishedSortedByVersion
from undeclared class \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open
Open
$nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getSiteId
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$siteId = $node->getSiteId();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
- Create a ticketCreate a ticket
- Exclude checks
Call to method getNodeId
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$node->getNodeId(),
- Create a ticketCreate a ticket
- Exclude checks
Call to method getRoutePattern
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
- Create a ticketCreate a ticket
- Exclude checks
Call to method getNodeId
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$node->getNodeId(),
- Create a ticketCreate a ticket
- Exclude checks
Parameter $siteRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant REDIRECTION_CREATE
from undeclared class \OpenOrchestra\ModelInterface\RedirectionEvents
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Call to method findByNode
from undeclared class \OpenOrchestra\ModelInterface\Repository\RedirectionRepositoryInterface
Open
Open
$redirections = $this->redirectionRepository->findByNode($nodeId, $language, $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $eventDispatcher
has undeclared type \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method dispatch
from undeclared class \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $redirectionRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\RedirectionRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\RedirectionEvent
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
if ($parent instanceof NodeInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getRoutePattern
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
- Create a ticketCreate a ticket
- Exclude checks
Parameter $nodeRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method dispatch
from undeclared class \Symfony\Component\EventDispatcher\EventDispatcherInterface
Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_DELETE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Call to method findOnePublished
from undeclared class \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open
Open
$parent = $this->nodeRepository->findOnePublished($parentId, $language, $siteId);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
Open
$node->getLanguage(),
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $redirectionRepository. Keep variable name length under 20. Open
Open
RedirectionRepositoryInterface $redirectionRepository
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
protected $redirectionRepository;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
){
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
Open
$oldRoutePattern = $this->completeRoutePattern($otherNode->getParentId(), $otherNode->getRoutePattern(), $otherNode->getLanguage());
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
Open
return str_replace('//', '/', $this->completeRoutePattern($parent->getParentId(), $parent->getRoutePattern() . '/' . $suffix, $language));
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
$redirection->setRoutePattern(preg_replace('#///|//#', '/', '/' . $alias->getPrefix() . '/' . $pattern));
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
Open
$routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
$this->eventDispatcher->dispatch(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
- Create a ticketCreate a ticket
- Exclude checks
Arguments with default values must be at the end of the argument list Open
Open
protected function completeRoutePattern($parentId = null, $suffix = null, $language)
- Create a ticketCreate a ticket
- Exclude checks
Multi-line function call not indented correctly; expected 20 spaces but found 24 Open
Open
);
- Create a ticketCreate a ticket
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
Open
);
- Create a ticketCreate a ticket
- Exclude checks