open-orchestra/open-orchestra-cms-bundle

View on GitHub
ApiBundle/Transformer/ContentTypeTransformer.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

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

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

        $facadeClass,
        MultiLanguagesChoiceManagerInterface $multiLanguagesChoiceManager,
        ContentRepositoryInterface $contentRepository,
        ContentTypeRepositoryInterface $contentTypeRepository,
        AuthorizationCheckerInterface $authorizationChecker,
Severity: Major
Found in ApiBundle/Transformer/ContentTypeTransformer.php - About 50 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($contentType, 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($contentType, array $params = array())

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

        $facade->version = $contentType->getVersion();

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

                $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE)

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

    public function __construct(

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

        $facade->name = $this->multiLanguagesChoiceManager->choose($contentType->getNames());

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

        $facade->definingStatusable = $contentType->isDefiningStatusable();

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

                $contentType->isLinkedToSite() && $contentType->isAlwaysShared(),

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

            return $this->contentTypeRepository->findOneByContentTypeIdInLastVersion($facade->contentTypeId);

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

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

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

    public function __construct(

Parameter $contentType has undeclared type \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

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

Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTypeTransformer->authorizationChecker
Open

                $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE)

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

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

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

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

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

        $facade->linkedToSite = $contentType->isLinkedToSite();

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

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

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

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

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

        $facade->definingVersionable = $contentType->isDefiningVersionable();

Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTypeTransformer->authorizationChecker
Open

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE));

Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTypeTransformer->authorizationChecker
Open

            $facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $contentType) &&

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

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

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTypeTransformer::getContext
Open

                $facade->addField($this->getContext()->transform('field_type', $field));

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

    public function __construct(

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

        $facade = $this->newFacade();

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

            return $this->contentTypeRepository->findOneByContentTypeIdInLastVersion($facade->contentTypeId);

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

        $facade->contentTypeId = $contentType->getContentTypeId();

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

                $contentType->isDefiningStatusable()

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

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

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

        if (!$contentType instanceof ContentTypeInterface) {

Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTypeTransformer->authorizationChecker
Open

                $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, $content)

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

            foreach ($contentType->getFields() as $field) {

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

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

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

class ContentTypeTransformer extends AbstractSecurityCheckerAwareTransformer

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

        $facade->defaultListable = $contentType->getDefaultListable();

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

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE));

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

                $contentType->isLinkedToSite() && $contentType->isAlwaysShared(),

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

            throw new TransformerParameterTypeException();

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

        $facade->name = $this->multiLanguagesChoiceManager->choose($contentType->getNames());

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

                $contentType->getContentTypeId(),

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 $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

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 $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

Blank line found at start of control structure
Open

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

Blank line found at end of control structure
Open


Line exceeds 120 characters; contains 159 characters
Open

            $facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE));

Line exceeds 120 characters; contains 136 characters
Open

            $facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $contentType) &&

Line exceeds 120 characters; contains 126 characters
Open

                $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentTypeInterface::ENTITY_TYPE)

There are no issues that match your filters.

Category
Status