open-orchestra/open-orchestra-cms-bundle

View on GitHub
ApiBundle/Transformer/BlockTransformer.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

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

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

        $facadeClass,
        DisplayBlockManager      $displayBlockManager,
        BlockConfigurationManager $blockConfigurationManager,
        TranslatorInterface $translator,
        NodeRepositoryInterface $nodeRepository,
Severity: Major
Found in ApiBundle/Transformer/BlockTransformer.php - About 50 mins to fix

Function transform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function transform($block, array $params = array())
    {
        if (!$block instanceof BlockInterface) {
            throw new TransformerParameterTypeException();
        }
Severity: Minor
Found in ApiBundle/Transformer/BlockTransformer.php - About 25 mins 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 '$params'.
Open

    public function transform($block, 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 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

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

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

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

        parent::__construct($facadeClass);
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::newFacade
Open

        $facade = $this->newFacade();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getComponent from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->name = $this->blockConfigurationManager->getBlockComponentName($block->getComponent());
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method findById from undeclared class \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open

        return $this->blockRepository->findById($facade->id);
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

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

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

        $facade->language = $block->getLanguage();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Parameter $block has undeclared type \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

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

Call to method getLabel from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->label = $block->getLabel();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getStyle from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->style = $block->getStyle();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getAttributes from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        foreach ($block->getAttributes() as $key => $attribute) {
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

            $facade->numberUse = $this->nodeRepository->countBlockUsed($block->getId());
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

        return $this->blockRepository->findById($facade->id);

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

    public function __construct(

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

        if (!$block instanceof BlockInterface) {
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::BLOCK_REQUIRED_URI_PARAMETERS)) {
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

class BlockTransformer extends AbstractTransformer
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getComponent from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->component = $block->getComponent();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getComponent from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $categoryKey = $this->blockConfigurationManager->getBlockCategory($block->getComponent());
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open

        if ($this->hasGroup(CMSGroupContext::BLOCKS_NUMBER_USE)) {
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

    public function __construct(

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

        $facade->id = $block->getId();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method getUpdatedAt from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->updatedAt = $block->getUpdatedAt();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

            'label' => $this->translator->trans($categoryKey),
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open

        return $this->hasGroup(CMSGroupContext::AREAS);
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

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

Parameter $blockRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open

    public function __construct(

Argument 1 (block) is \OpenOrchestra\ModelInterface\Model\BlockInterface but \OpenOrchestra\Backoffice\DisplayBlock\DisplayBlockManager::show() takes \OpenOrchestra\ModelInterface\Model\ReadBlockInterface defined at /code/Backoffice/DisplayBlock/DisplayBlockManager.php:47
Open

        $facade->previewContent = $this->displayBlockManager->show($block);

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

            throw new TransformerParameterTypeException();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Call to method isTransverse from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

        $facade->transverse = $block->isTransverse();
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

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

            $facade->numberUse = $this->nodeRepository->countBlockUsed($block->getId());
Severity: Critical
Found in ApiBundle/Transformer/BlockTransformer.php by phan

Return type of reverseTransform() is undeclared type \OpenOrchestra\ModelInterface\Model\BlockInterface
Open

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

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

        BlockConfigurationManager $blockConfigurationManager,

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

    protected $blockConfigurationManager;

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 are no issues that match your filters.

Category
Status