ApiBundle/Transformer/BlockTransformer.php
Method transform
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function transform($block, array $params = array())
{
if (!$block instanceof BlockInterface) {
throw new TransformerParameterTypeException();
}
- Create a ticketCreate a ticket
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
$facadeClass,
DisplayBlockManager $displayBlockManager,
BlockConfigurationManager $blockConfigurationManager,
TranslatorInterface $translator,
NodeRepositoryInterface $nodeRepository,
- Create a ticketCreate a ticket
Function transform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
public function transform($block, array $params = array())
{
if (!$block instanceof BlockInterface) {
throw new TransformerParameterTypeException();
}
- Read upRead up
- Create a ticketCreate a ticket
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
Open
public function transform($block, array $params = array())
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
public function reverseTransform(FacadeInterface $facade, array $params = array())
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
public function transform($block, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractTransformer
Open
Open
parent::__construct($facadeClass);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::newFacade
Open
Open
$facade = $this->newFacade();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getComponent
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->name = $this->blockConfigurationManager->getBlockComponentName($block->getComponent());
- Create a ticketCreate a ticket
- Exclude checks
Call to method findById
from undeclared class \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open
Open
return $this->blockRepository->findById($facade->id);
- Create a ticketCreate a ticket
- Exclude checks
Return type of transform()
is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
public function transform($block, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->language = $block->getLanguage();
- Create a ticketCreate a ticket
- Exclude checks
Parameter $block
has undeclared type \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
public function transform($block, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLabel
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->label = $block->getLabel();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getStyle
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->style = $block->getStyle();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getAttributes
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
foreach ($block->getAttributes() as $key => $attribute) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getId
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->numberUse = $this->nodeRepository->countBlockUsed($block->getId());
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property id
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
return $this->blockRepository->findById($facade->id);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $translator
has undeclared type \Symfony\Component\Translation\TranslatorInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
if (!$block instanceof BlockInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open
Open
if ($this->hasGroup(CMSGroupContext::BLOCK_REQUIRED_URI_PARAMETERS)) {
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractTransformer
Open
Open
class BlockTransformer extends AbstractTransformer
- Create a ticketCreate a ticket
- Exclude checks
Call to method getComponent
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->component = $block->getComponent();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getComponent
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$categoryKey = $this->blockConfigurationManager->getBlockCategory($block->getComponent());
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open
Open
if ($this->hasGroup(CMSGroupContext::BLOCKS_NUMBER_USE)) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $nodeRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getId
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->id = $block->getId();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUpdatedAt
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->updatedAt = $block->getUpdatedAt();
- Create a ticketCreate a ticket
- Exclude checks
Call to method trans
from undeclared class \Symfony\Component\Translation\TranslatorInterface
Open
Open
'label' => $this->translator->trans($categoryKey),
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\BlockTransformer::hasGroup
Open
Open
return $this->hasGroup(CMSGroupContext::AREAS);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $facade
has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
public function reverseTransform(FacadeInterface $facade, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Parameter $blockRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\BlockRepositoryInterface
Open
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
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
Open
$facade->previewContent = $this->displayBlockManager->show($block);
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open
Open
throw new TransformerParameterTypeException();
- Create a ticketCreate a ticket
- Exclude checks
Call to method isTransverse
from undeclared class \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
$facade->transverse = $block->isTransverse();
- Create a ticketCreate a ticket
- Exclude checks
Call to method countBlockUsed
from undeclared class \OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface
Open
Open
$facade->numberUse = $this->nodeRepository->countBlockUsed($block->getId());
- Create a ticketCreate a ticket
- Exclude checks
Return type of reverseTransform()
is undeclared type \OpenOrchestra\ModelInterface\Model\BlockInterface
Open
Open
public function reverseTransform(FacadeInterface $facade, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $blockConfigurationManager. Keep variable name length under 20. Open
Open
BlockConfigurationManager $blockConfigurationManager,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Open
protected $blockConfigurationManager;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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++ ) {
}
}
}