open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/EventSubscriber/ContentTypeStatusableSubscriber.php

Summary

Maintainability
A
0 mins
Test Coverage

The method preSubmit uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $status = $this->statusRepository->findOneByOutOfWorkflow();
            }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

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

                $status = $this->statusRepository->findOneByOutOfWorkflow();

Call to method isDefiningStatusable from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

            && $contentType->isDefiningStatusable() != $data['definingStatusable']

Parameter $event has undeclared type \Symfony\Component\Form\FormEvent
Open

    public function preSubmit(FormEvent $event)

Call to method getData from undeclared class \Symfony\Component\Form\FormEvent
Open

        $data = $event->getData();

Call to method updateStatusByContentType from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open

            $this->contentRepository->updateStatusByContentType($status, $contentType->getContentTypeId());

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

class ContentTypeStatusableSubscriber implements EventSubscriberInterface

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

                $status = $this->statusRepository->findOneByInitial();

Reference to constant PRE_SUBMIT from undeclared class \Symfony\Component\Form\FormEvents
Open

            FormEvents::PRE_SUBMIT => 'preSubmit',

Parameter $contentRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open

    public function __construct(

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

    public function __construct(

Call to method getContentTypeId from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

            $this->contentRepository->updateStatusByContentType($status, $contentType->getContentTypeId());

Call to method getForm from undeclared class \Symfony\Component\Form\FormEvent
Open

        $contentType = $event->getForm()->getData();

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

        if ($contentType instanceof ContentTypeInterface

Line exceeds 120 characters; contains 123 characters
Open

        $data['definingStatusable'] = !array_key_exists('definingStatusable', $data) ? false : $data['definingStatusable'];

There are no issues that match your filters.

Category
Status