open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/BusinessRules/Strategies/NodeStrategy.php

Summary

Maintainability
A
1 hr
Test Coverage

Function canChangeToPublishStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function canChangeToPublishStatus(NodeInterface $node, array $parameters)
    {
        $areas = $node->getAreas();
        $routePattern = $node->getRoutePattern();
        foreach ($areas as $area) {
Severity: Minor
Found in Backoffice/BusinessRules/Strategies/NodeStrategy.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

Avoid unused parameters such as '$parameters'.
Open

    public function canDeleteVersion(NodeInterface $node, array $parameters)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$parameters'.
Open

    public function canDelete(NodeInterface $node, array $parameters)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused parameters such as '$parameters'.
Open

    public function canEdit(NodeInterface $node, array $parameters)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

            false === $this->nodeRepository->hasNodeIdWithoutAutoUnpublishToState($node->getNodeId(), $node->getSiteId()) &&

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        return NodeInterface::ENTITY_TYPE;

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

        return !$node->getStatus()->isBlockedEdition();

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

    public function canDelete(NodeInterface $node, array $parameters)

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

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

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

            $this->nodeRepository->countByParentId($node->getNodeId(), $node->getSiteId()) == 0;

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

    public function canDeleteVersion(NodeInterface $node, array $parameters)

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

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

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

        if ($node->getStatus() instanceof StatusInterface && $node->getStatus()->isPublishedState()) {

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

    public function canChangeToPublishStatus(NodeInterface $node, array $parameters)

Reference to constant ROOT_NODE_ID from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        return $node->getNodeId() !== NodeInterface::ROOT_NODE_ID &&

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

            false === $this->nodeRepository->hasNodeIdWithoutAutoUnpublishToState($node->getNodeId(), $node->getSiteId()) &&

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

    public function canEdit(NodeInterface $node, array $parameters)

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

        $routePattern = $node->getRoutePattern();

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

            false === $this->nodeRepository->hasNodeIdWithoutAutoUnpublishToState($node->getNodeId(), $node->getSiteId()) &&

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

            $this->nodeRepository->countByParentId($node->getNodeId(), $node->getSiteId()) == 0;

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

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

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

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

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

            $this->nodeRepository->countByParentId($node->getNodeId(), $node->getSiteId()) == 0;

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

    public function canChangeStatus(NodeInterface $node, array $parameters)

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

    public function __construct(

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

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

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

        return $node->getNodeId() !== NodeInterface::ROOT_NODE_ID &&

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

        if ($node->getStatus() instanceof StatusInterface && $node->getStatus()->isPublishedState()) {

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

        $areas = $node->getAreas();

PHP keywords must be lowercase; expected "const" but found "CONST"
Open

    CONST CHANGE_TO_PUBLISH_STATUS  = 'CHANGE_TO_PUBLISH_STATUS';

PHP keywords must be lowercase; expected "const" but found "CONST"
Open

    CONST CHANGE_STATUS  = 'CHANGE_STATUS';

PHP keywords must be lowercase; expected "const" but found "CONST"
Open

    CONST DELETE_VERSION = 'DELETE_VERSION';

Line exceeds 120 characters; contains 124 characters
Open

            false === $this->nodeRepository->hasNodeIdWithoutAutoUnpublishToState($node->getNodeId(), $node->getSiteId()) &&

Line exceeds 120 characters; contains 171 characters
Open

        return $this->nodeRepository->countNotDeletedVersions($node->getNodeId(), $node->getLanguage(), $node->getSiteId()) > 1 && !$node->getStatus()->isPublishedState();

There are no issues that match your filters.

Category
Status