Method transform
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transform($content, array $params = array())
{
if (!$content instanceof ContentInterface) {
throw new TransformerParameterTypeException();
}
- Create a ticketCreate a ticket
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$facadeClass,
StatusRepositoryInterface $statusRepository,
ContentRepositoryInterface $contentRepository,
AuthorizationCheckerInterface $authorizationChecker,
ContextBackOfficeInterface $contextManager,
- Create a ticketCreate a ticket
The class ContentTransformer has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class ContentTransformer extends AbstractSecurityCheckerAwareTransformer
{
protected $statusRepository;
protected $contentRepository;
protected $contextManager;
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Avoid unused parameters such as '$params'. Open
public function transform($content, 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
Parameter $content
has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
public function transform($content, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
if (!$content instanceof ContentInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $authorizationChecker
has undeclared type \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTransformer::getContext
Open
$facade->status = $this->getContext()->transform('status', $content->getStatus());
- Create a ticketCreate a ticket
- Exclude checks
Call to method getCreatedAt
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->createdAt = $content->getCreatedAt();
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open
throw new TransformerParameterTypeException();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getAttributes
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
foreach ($content->getAttributes() as $attribute) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTransformer->authorizationChecker
Open
$facade->addRight('can_delete_version', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property status
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
null !== $facade->status &&
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property status
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
null !== $facade->status->id &&
- Create a ticketCreate a ticket
- Exclude checks
Call to method getId
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->id = $content->getId();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->language = $content->getLanguage();
- Create a ticketCreate a ticket
- Exclude checks
Call to method isUsed
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->used = $content->isUsed();
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTransformer->authorizationChecker
Open
$facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentInterface::ENTITY_TYPE));
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open
parent::__construct($facadeClass, $authorizationChecker);
- Create a ticketCreate a ticket
- Exclude checks
Call to method findById
from undeclared class \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
return $this->contentRepository->findById($facade->id);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $statusRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method find
from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open
$status = $this->statusRepository->find($facade->status->id);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $contentRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getContentType
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->contentType = $content->getContentType();
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTransformer::newFacade
Open
$facade = $this->newFacade();
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$params['source'] instanceof ContentInterface &&
- Create a ticketCreate a ticket
- Exclude checks
Call to method getStatus
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->statusLabel = $content->getStatus()->getLabel($this->contextManager->getBackOfficeLanguage());
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTransformer->authorizationChecker
Open
$facade->addRight('can_edit', $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $content));
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property status
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
$status = $this->statusRepository->find($facade->status->id);
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property id
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
if (null !== $facade->id) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getContentId
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->contentId = $content->getContentId();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getVersion
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->version = $content->getVersion();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getVersionName
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->versionName = $content->getVersionName();
- Create a ticketCreate a ticket
- Exclude checks
@throws annotation of reverseTransform
has suspicious class type \OpenOrchestra\ApiBundle\Exceptions\HttpException\StatusChangeNotGrantedHttpException,
which does not extend Error/Exception Open
public function reverseTransform(FacadeInterface $facade, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \OpenOrchestra\BaseApi\Transformer\AbstractSecurityCheckerAwareTransformer
Open
class ContentTransformer extends AbstractSecurityCheckerAwareTransformer
- Create a ticketCreate a ticket
- Exclude checks
Call to method isDeleted
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->deleted = $content->isDeleted();
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
if ($status instanceof StatusInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Return type of transform()
is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
public function transform($content, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
@throws type of transform
has undeclared type \OpenOrchestra\BaseApi\Exceptions\TransformerParameterTypeException
Open
public function transform($content, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Call to method getName
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->name = $content->getName();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUpdatedAt
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->updatedAt = $content->getUpdatedAt();
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTransformer::hasGroup
Open
if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS)) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getStatus
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->status = $this->getContext()->transform('status', $content->getStatus());
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTransformer::getContext
Open
$contentAttribute = $this->getContext()->transform('content_attribute', $attribute);
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property status
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
$params['source']->getStatus()->getId() !== $facade->status->id
- Create a ticketCreate a ticket
- Exclude checks
Call to method getCreatedBy
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->createdBy = $content->getCreatedBy();
- Create a ticketCreate a ticket
- Exclude checks
Call to method isLinkedToSite
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->linkedToSite = $content->isLinkedToSite();
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\ContentTransformer::hasGroup
Open
if ($this->hasGroup(CMSGroupContext::AUTHORIZATIONS_DELETE_VERSION)) {
- Create a ticketCreate a ticket
- Exclude checks
Reference to instance property id
from undeclared class \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
return $this->contentRepository->findById($facade->id);
- Create a ticketCreate a ticket
- Exclude checks
Reference to undeclared property \OpenOrchestra\ApiBundle\Transformer\ContentTransformer->authorizationChecker
Open
$facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentInterface::ENTITY_TYPE));
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUpdatedBy
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open
$facade->updatedBy = $content->getUpdatedBy();
- Create a ticketCreate a ticket
- Exclude checks
Parameter $facade
has undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
public function reverseTransform(FacadeInterface $facade, array $params = array())
- Create a ticketCreate a ticket
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (array_key_exists('source', $params) &&
$params['source'] instanceof ContentInterface &&
null !== $facade->status &&
null !== $facade->status->id &&
$params['source']->getStatus()->getId() !== $facade->status->id
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 120.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Line exceeds 120 characters; contains 132 characters Open
$facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$facade->addRight('can_edit', $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $content));
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
$facade->addRight('can_delete_version', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
$facade->addRight('can_duplicate', $this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, ContentInterface::ENTITY_TYPE));
- Create a ticketCreate a ticket
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$facade->addRight('can_delete_version', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $content) &&
- Create a ticketCreate a ticket
- Exclude checks