open-orchestra/open-orchestra-cms-bundle

View on GitHub
WorkflowAdminBundle/EventSubscriber/AddGroupWorkflowProfileSubscriber.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method addWorkflowProfile has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addWorkflowProfile(GroupFormEvent $event)
    {
        $builder = $event->getBuilder();
        $group = $builder->getData();
        $configuration = array();

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

        WorkflowProfileRepositoryInterface $workflowProfileRepository,
        ContentTypeRepositoryInterface $contentTypeRepository,
        DataTransformerInterface $workflowProfileCollectionTransformer,
        ContextBackOfficeInterface $contextManager,
        TranslatorInterface $translator

Function addWorkflowProfile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addWorkflowProfile(GroupFormEvent $event)
    {
        $builder = $event->getBuilder();
        $group = $builder->getData();
        $configuration = array();

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

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

        $group = $builder->getData();

Call to method get from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->get('workflow_profile_collections')->addModelTransformer($this->workflowProfileCollectionTransformer);

Call to method findAllNotDeletedInLastVersion from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface
Open

                $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion($site->getContentTypes());

Call to method add from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->add('workflow_profile_collections', 'oo_check_list_collection', array(

Call to method getContentTypes from undeclared class \OpenOrchestra\ModelInterface\Model\ReadSiteInterface
Open

                $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion($site->getContentTypes());

Call to method setAttribute from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->setAttribute('sub_group_render', array_merge($builder->getAttribute('sub_group_render'), array(

Parameter $workflowProfileCollectionTransformer has undeclared type \Symfony\Component\Form\DataTransformerInterface
Open

    public function __construct(

Call to method getAttribute from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->setAttribute('sub_group_render', array_merge($builder->getAttribute('sub_group_render'), array(

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

class AddGroupWorkflowProfileSubscriber implements EventSubscriberInterface

Parameter $workflowProfileRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open

    public function __construct(

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

        $configuration['default']['column'][NodeInterface::ENTITY_TYPE] = $this->translator->trans('open_orchestra_workflow_admin.profile.page');

Call to method getContentTypes from undeclared class \OpenOrchestra\ModelInterface\Model\ReadSiteInterface
Open

            if (!empty($site->getContentTypes())) {

Call to method getAttribute from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->setAttribute('group_render', array_merge($builder->getAttribute('group_render'), array(

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

    public function __construct(

Call to method findAll from undeclared class \OpenOrchestra\ModelInterface\Repository\WorkflowProfileRepositoryInterface
Open

        $workflowProfiles = $this->workflowProfileRepository->findAll();

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

        $configuration['default']['column'][NodeInterface::ENTITY_TYPE] = $this->translator->trans('open_orchestra_workflow_admin.profile.page');

Call to method setAttribute from undeclared class \Symfony\Component\Form\FormBuilderInterface
Open

        $builder->setAttribute('group_render', array_merge($builder->getAttribute('group_render'), array(

Parameter $contentTypeRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentTypeRepositoryInterface
Open

    public function __construct(

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

    protected $contentTypeRepository;

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

    protected $workflowProfileCollectionTransformer;

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

        DataTransformerInterface $workflowProfileCollectionTransformer,

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

        WorkflowProfileRepositoryInterface $workflowProfileRepository,

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

    protected $workflowProfileRepository;

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

        ContentTypeRepositoryInterface $contentTypeRepository,

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 145 characters
Open

        $configuration['default']['column'][NodeInterface::ENTITY_TYPE] = $this->translator->trans('open_orchestra_workflow_admin.profile.page');

Line exceeds 120 characters; contains 162 characters
Open

                    $configuration['default']['column'][$contentType->getContentTypeId()] = $contentType->getName($this->contextManager->getBackOfficeLanguage());

Line exceeds 120 characters; contains 124 characters
Open

            $configuration['default']['row'][] = $workflowProfile->getLabel($this->contextManager->getBackOfficeLanguage());

Line indented incorrectly; expected 4 spaces, found 3
Open

   }

Closing brace indented incorrectly; expected 4 spaces, found 3
Open

   }

There are no issues that match your filters.

Category
Status