open-orchestra/open-orchestra-cms-bundle

View on GitHub
WorkflowAdminBundle/Transformer/StatusTransformer.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method transform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function transform($status, array $params = array())
    {
        if (!$status instanceof StatusInterface) {
            throw new TransformerParameterTypeException();
        }
Severity: Minor
Found in WorkflowAdminBundle/Transformer/StatusTransformer.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {
            $canDelete = $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $status)
                && !$this->usageFinder->hasUsage($status)
                && !$status->isInitialState()
                && !$status->isPublishedState()
Severity: Major
Found in WorkflowAdminBundle/Transformer/StatusTransformer.php - About 1 hr to fix

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

        $facadeClass,
        MultiLanguagesChoiceManagerInterface $multiLanguagesChoiceManager,
        TranslatorInterface $translator,
        AuthorizationCheckerInterface $authorizationChecker,
        StatusUsageFinder $usageFinder,
Severity: Minor
Found in WorkflowAdminBundle/Transformer/StatusTransformer.php - About 45 mins to fix

Avoid unused parameters such as '$params'.
Open

    public function reverseTransform(FacadeInterface $facade, array $params = array())

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 '$params'.
Open

    public function transform($status, array $params = array())

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 undeclared method \OpenOrchestra\WorkflowAdminBundle\Transformer\StatusTransformer::newFacade
Open

        $facade = $this->newFacade();

Call to method getId from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->id = $status->getId();

Parameter $multiLanguagesChoiceManager has undeclared type \OpenOrchestra\ModelInterface\Manager\MultiLanguagesChoiceManagerInterface
Open

    public function __construct(

Reference to undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open

        parent::__construct($facadeClass, $authorizationChecker);

Call to method isInitialState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->initialState = $status->isInitialState();

Call to method isAutoPublishFromState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->autoPublishFromState = $status->isAutoPublishFromState();

Call to method getLabels from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->label = $this->multiLanguagesChoiceManager->choose($status->getLabels());

Call to method isAutoUnpublishToState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

                && !$status->isAutoUnpublishToState();

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

    public function __construct(

Parameter $status has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

    public function transform($status, array $params = array())

Call to method isAutoUnpublishToState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->autoUnpublishToState = $status->isAutoUnpublishToState();

Call to method getName from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->name = $status->getName();

Call to method choose from undeclared class \OpenOrchestra\ModelInterface\Manager\MultiLanguagesChoiceManagerInterface
Open

        $facade->label = $this->multiLanguagesChoiceManager->choose($status->getLabels());

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

            return $this->statusRepository->find($facade->id);

Call to method isAutoPublishFromState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

                && !$status->isAutoPublishFromState()

Parameter $translator has undeclared type \Symfony\Component\Translation\TranslatorInterface
Open

    public function __construct(

Call to method isPublishedState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->publishedState = $status->isPublishedState();

Call to method isTranslationState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->translationState = $status->isTranslationState();

Class extends undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open

class StatusTransformer extends AbstractSecurityCheckerAwareTransformer

Parameter $authorizationChecker has undeclared type \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open

    public function __construct(

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

        if (!$status instanceof StatusInterface) {

Call to method isInitialState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

                && !$status->isInitialState()

Return type of reverseTransform() is undeclared type \OpenOrchestra\WorkflowAdminBundle\Transformer\UserInterface
Open

    public function reverseTransform(FacadeInterface $facade, array $params = array())

Call to method getDisplayColor from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->displayColor = $this->translator->trans('open_orchestra_workflow_admin.form.status.color.' . $status->getDisplayColor());

Parameter $facade has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function reverseTransform(FacadeInterface $facade, array $params = array())

Reference to instance property id from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

        if (null !== $facade->id) {

Call to method isPublishedState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

                && !$status->isPublishedState()

Call to method isTranslationState from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

                && !$status->isTranslationState()

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Transformer\StatusTransformer::hasGroup
Open

        return $this->hasGroup(CMSGroupContext::STATUS);

Call to method __construct from undeclared class \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open

            throw new TransformerParameterTypeException();

Return type of transform() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function transform($status, array $params = array())

Call to method isBlockedEdition from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->blockedEdtion = $status->isBlockedEdition();

Call to method getDisplayColor from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open

        $facade->codeColor = $status->getDisplayColor();

Call to undeclared method \OpenOrchestra\WorkflowAdminBundle\Transformer\StatusTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {

@throws type of transform has undeclared type \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open

    public function transform($status, array $params = array())

Reference to instance property id from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

            return $this->statusRepository->find($facade->id);

Call to method trans from undeclared class \Symfony\Component\Translation\TranslatorInterface
Open

        $facade->displayColor = $this->translator->trans('open_orchestra_workflow_admin.form.status.color.' . $status->getDisplayColor());

Reference to undeclared property \OpenOrchestra\WorkflowAdminBundle\Transformer\StatusTransformer->authorizationChecker
Open

            $canDelete = $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $status)

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

    protected $multiLanguagesChoiceManager;

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

        MultiLanguagesChoiceManagerInterface $multiLanguagesChoiceManager,

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

Line exceeds 120 characters; contains 138 characters
Open

        $facade->displayColor = $this->translator->trans('open_orchestra_workflow_admin.form.status.color.' . $status->getDisplayColor());

There are no issues that match your filters.

Category
Status