ApiBundle/Controller/ContentTypeController.php
Function deleteAction
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public function deleteAction($contentTypeId)
{
if (0 == $this->get('open_orchestra_model.repository.content')->countByContentType($contentTypeId)) {
$contentTypes = $this->get('open_orchestra_model.repository.content_type')->findBy(array('contentTypeId' => $contentTypeId));
if (count($contentTypes) > 0) {
- 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 using static access to class '\OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration' in method 'listAction'. Open
Open
$configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Possibly zero references to use statement for classlike/namespace Api
(\OpenOrchestra\BaseApiBundle\Controller\Annotation)
Open
Open
use OpenOrchestra\BaseApiBundle\Controller\Annotation as Api;
- Create a ticketCreate a ticket
- Exclude checks
Parameter $request
has undeclared type \Symfony\Component\HttpFoundation\Request
Open
Open
public function deleteContentTypesAction(Request $request)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$contentTypeRepository = $this->get('open_orchestra_model.repository.content_type');
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\ContentTypeEvent
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentType));
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$siteId = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteId();
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$contentType = $this->get('open_orchestra_model.repository.content_type')->findOneByContentTypeIdInLastVersion($contentTypeId);
- Create a ticketCreate a ticket
- Exclude checks
Return type of deleteContentTypesAction()
is undeclared type \Symfony\Component\HttpFoundation\Response
Open
Open
public function deleteContentTypesAction(Request $request)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$site = $this->get('open_orchestra_model.repository.site')->findOneBySiteId($siteId);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::dispatchEvent
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentTypes[0]));
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace Config
(\Sensio\Bundle\FrameworkExtraBundle\Configuration)
Open
Open
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
- Create a ticketCreate a ticket
- Exclude checks
Parameter $request
has undeclared type \Symfony\Component\HttpFoundation\Request
Open
Open
public function listAction(Request $request)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$facade = $this->get('open_orchestra_api.transformer_manager')->transform('content_type_collection', $collection);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$facade = $this->get('jms_serializer')->deserialize(
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::getParameter
Open
Open
$this->getParameter('open_orchestra_api.facade.content_type_collection.class'),
- Create a ticketCreate a ticket
- Exclude checks
Class extends undeclared class \OpenOrchestra\BaseApiBundle\Controller\BaseController
Open
Open
class ContentTypeController extends BaseController
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentType)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::isGranted
Open
Open
if ($this->isGranted(ContributionActionInterface::DELETE, $contentType) &&
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant CONTENT_TYPE_DELETE
from undeclared class \OpenOrchestra\ModelInterface\ContentTypeEvents
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentType));
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
if (0 == $this->get('open_orchestra_model.repository.content')->countByContentType($contentTypeId)) {
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
return $this->get('open_orchestra_api.transformer_manager')->transform('content_type', $contentType);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::dispatchEvent
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentType));
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\ContentTypeEvent
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentTypes[0]));
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::denyAccessUnlessGranted
Open
Open
$this->denyAccessUnlessGranted(ContributionActionInterface::READ, ContentTypeInterface::ENTITY_TYPE);
- Create a ticketCreate a ticket
- Exclude checks
Call to method get
from undeclared class \Symfony\Component\HttpFoundation\Request
Open
Open
$format = $request->get('_format', 'json');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$contentTypes = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content_type_collection', $facade);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$repository = $this->get('open_orchestra_model.repository.content_type');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$repository = $this->get('open_orchestra_model.repository.content_type');
- Create a ticketCreate a ticket
- Exclude checks
@throws type of deleteAction
has undeclared type \OpenOrchestra\ApiBundle\Controller\ContentTypeNotAllowedException
Open
Open
public function deleteAction($contentTypeId)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentTypes[0])) {
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::createAccessDeniedException
Open
Open
$this->createAccessDeniedException();
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant CONTENT_TYPE_DELETE
from undeclared class \OpenOrchestra\ModelInterface\ContentTypeEvents
Open
Open
$this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_DELETE, new ContentTypeEvent($contentTypes[0]));
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant ENTITY_TYPE
from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open
Open
$this->denyAccessUnlessGranted(ContributionActionInterface::READ, ContentTypeInterface::ENTITY_TYPE);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$contentTypes = $this->get('open_orchestra_model.repository.content_type')->findBy(array('contentTypeId' => $contentTypeId));
- Create a ticketCreate a ticket
- Exclude checks
Return type of deleteAction()
is undeclared type \Symfony\Component\HttpFoundation\Response
Open
Open
public function deleteAction($contentTypeId)
- Create a ticketCreate a ticket
- Exclude checks
Call to method getContent
from undeclared class \Symfony\Component\HttpFoundation\Request
Open
Open
$request->getContent(),
- Create a ticketCreate a ticket
- Exclude checks
Returning type array{}
but deleteContentTypesAction()
is declared to return \Symfony\Component\HttpFoundation\Response
Open
Open
return array();
- Create a ticketCreate a ticket
- Exclude checks
Return type of listForContentAction()
is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
public function listForContentAction()
- Create a ticketCreate a ticket
- Exclude checks
Return type of showAction()
is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
public function showAction($contentTypeId)
- Create a ticketCreate a ticket
- Exclude checks
Call to method generateFromRequest
from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open
Open
$configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$facade = $this->get('open_orchestra_api.transformer_manager')->transform('content_type_collection', $collection);
- Create a ticketCreate a ticket
- Exclude checks
Return type of listAction()
is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open
Open
public function listAction(Request $request)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::denyAccessUnlessGranted
Open
Open
$this->denyAccessUnlessGranted(ContributionActionInterface::DELETE, $contentType);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$this->get('open_orchestra_backoffice.manager.content_type')->delete($contentTypes);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\ApiBundle\Controller\ContentTypeController::get
Open
Open
$this->get('object_manager')->flush();
- Create a ticketCreate a ticket
- Exclude checks
Returning type array{}
but deleteAction()
is declared to return \Symfony\Component\HttpFoundation\Response
Open
Open
return array();
- Create a ticketCreate a ticket
- Exclude checks
Avoid excessively long variable names like $contentTypeRepository. Keep variable name length under 20. Open
Open
$contentTypeRepository = $this->get('open_orchestra_model.repository.content_type');
- 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
Line exceeds 120 characters; contains 137 characters Open
Open
$contentTypes = $this->get('open_orchestra_model.repository.content_type')->findBy(array('contentTypeId' => $contentTypeId));
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
Open
$contentType = $this->get('open_orchestra_model.repository.content_type')->findOneByContentTypeIdInLastVersion($contentTypeId);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
Open
$contentTypes = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('content_type_collection', $facade);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
$facade = $this->get('open_orchestra_api.transformer_manager')->transform('content_type_collection', $collection);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
Open
if (!$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentTypes[0])) {
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
$this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentType)
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
$facade = $this->get('open_orchestra_api.transformer_manager')->transform('content_type_collection', $collection);
- Create a ticketCreate a ticket
- Exclude checks