Method newAction
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function newAction(Request $request, $siteId, $language, $parentId, $order)
{
$order = (int) $order;
$nodeManager = $this->get('open_orchestra_backoffice.manager.node');
$nodeRepository = $this->get('open_orchestra_model.repository.node');
- Create a ticketCreate a ticket
Method formAction
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function formAction(Request $request, $siteId, $nodeId, $language, $version)
{
$nodeRepository = $this->get('open_orchestra_model.repository.node');
if (null === $version) {
$node = $nodeRepository->findInLastVersion($nodeId, $language, $siteId);
- Create a ticketCreate a ticket
Function newAction
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function newAction(Request $request, $siteId, $language, $parentId, $order)
{
$order = (int) $order;
$nodeManager = $this->get('open_orchestra_backoffice.manager.node');
$nodeRepository = $this->get('open_orchestra_model.repository.node');
- 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
Method formAction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function formAction(Request $request, $siteId, $nodeId, $language, $version)
- Create a ticketCreate a ticket
Method newAction
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function newAction(Request $request, $siteId, $language, $parentId, $order)
- Create a ticketCreate a ticket
Method createForm
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
- Create a ticketCreate a ticket
Function formAction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function formAction(Request $request, $siteId, $nodeId, $language, $version)
{
$nodeRepository = $this->get('open_orchestra_model.repository.node');
if (null === $version) {
$node = $nodeRepository->findInLastVersion($nodeId, $language, $siteId);
- 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
Missing class import via use statement (line '45', column '23'). Open
throw new \UnexpectedValueException();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method formAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$node = $nodeRepository->findVersionNotDeleted($nodeId, $language, $siteId, $version);
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Expected @param annotation for language
to be before the @param annotation for version
Open
* @param string $version
- Create a ticketCreate a ticket
- Exclude checks
Return type of formAction()
is undeclared type \Symfony\Component\HttpFoundation\Response
Open
public function formAction(Request $request, $siteId, $nodeId, $language, $version)
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
if (!$node instanceof NodeInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $node),
- Create a ticketCreate a ticket
- Exclude checks
Possibly zero references to use statement for classlike/namespace Config
(\Sensio\Bundle\FrameworkExtraBundle\Configuration)
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
public function formAction(Request $request, $siteId, $nodeId, $language, $version)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$this->get('object_manager')->flush();
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant NODE_UPDATE
from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open
$this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
$nodesEvent[] = new NodeEvent($node);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$message = $this->get('translator')->trans('open_orchestra_backoffice.form.node.success');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$nodeRepository = $this->get('open_orchestra_model.repository.node');
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
$this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$message = $this->get('translator')->trans('open_orchestra_backoffice.form.node.success');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$documentManager = $this->get('object_manager');
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (form)
is \Symfony\Component\Form\Form
but \OpenOrchestra\BackofficeBundle\Controller\NodeController::renderAdminForm()
takes \Symfony\Component\Form\FormInterface
defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:58
Open
return $this->renderAdminForm($form);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $status
has undeclared type \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
- Create a ticketCreate a ticket
- Exclude checks
Return type of createForm()
is undeclared type \Symfony\Component\Form\Form
Open
public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
- Create a ticketCreate a ticket
- Exclude checks
Call to method isValid
from undeclared class \Symfony\Component\Form\Form
Open
if ($form->isValid()) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method handleRequest
from undeclared class \Symfony\Component\Form\Form
Open
$form->handleRequest($request);
- Create a ticketCreate a ticket
- Exclude checks
Call to method isValid
from undeclared class \Symfony\Component\Form\Form
Open
if ($form->isValid()) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $type
has undeclared type \Symfony\Component\Form\FormTypeInterface
Open
public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::isGranted
Open
'delete_button' => $this->isGranted(ContributionActionInterface::DELETE, $node)
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant NODE_CREATION
from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open
$this->dispatchEvent(NodeEvents::NODE_CREATION, $nodeEvent);
- Create a ticketCreate a ticket
- Exclude checks
Call to method isBlockedEdition
from undeclared class \OpenOrchestra\ModelInterface\Model\StatusInterface
Open
if (null !== $status && $status->isBlockedEdition()) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getTemplate
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
$template = $node->getTemplate();
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$node = $this->get('open_orchestra_backoffice.manager.node')->initializeAreasNode($node);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::generateUrl
Open
$url = $this->generateUrl('open_orchestra_backoffice_node_new', array(
- Create a ticketCreate a ticket
- Exclude checks
Call to method handleRequest
from undeclared class \Symfony\Component\Form\Form
Open
$form->handleRequest($request);
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (event)
is \OpenOrchestra\ModelInterface\Event\NodeEvent
but \OpenOrchestra\BackofficeBundle\Controller\NodeController::dispatchEvent()
takes \Symfony\Component\EventDispatcher\Event
defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open
$this->dispatchEvent(NodeEvents::NODE_CREATION, $nodeEvent);
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant HTTP_CREATED
from undeclared class \Symfony\Component\HttpFoundation\Response
Open
Response::HTTP_CREATED,
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::denyAccessUnlessGranted
Open
$this->denyAccessUnlessGranted(ContributionActionInterface::READ, $node);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getTemplate
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
if ($template !== $node->getTemplate()) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $request
has undeclared type \Symfony\Component\HttpFoundation\Request
Open
public function newAction(Request $request, $siteId, $language, $parentId, $order)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::denyAccessUnlessGranted
Open
$this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $node);
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (event)
is \OpenOrchestra\ModelInterface\Event\NodeEvent
but \OpenOrchestra\BackofficeBundle\Controller\NodeController::dispatchEvent()
takes \Symfony\Component\EventDispatcher\Event
defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:81
Open
$this->dispatchEvent(NodeEvents::NODE_UPDATE, new NodeEvent($node));
- Create a ticketCreate a ticket
- Exclude checks
Argument 1 (form)
is \Symfony\Component\Form\Form
but \OpenOrchestra\BackofficeBundle\Controller\NodeController::renderAdminForm()
takes \Symfony\Component\Form\FormInterface
defined at /code/BackofficeBundle/Controller/AbstractAdminController.php:58
Open
return $this->renderAdminForm($form);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$nodeManager = $this->get('open_orchestra_backoffice.manager.node');
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \Symfony\Component\HttpFoundation\Response
Open
$response = new Response(
- Create a ticketCreate a ticket
- Exclude checks
Argument 2 (data)
is \OpenOrchestra\ModelInterface\Model\NodeInterface
but \OpenOrchestra\BackofficeBundle\Controller\NodeController::createForm()
takes null
defined at /code/BackofficeBundle/Controller/NodeController.php:173
Open
$form = $this->createForm('oo_node', $node, $options, ContributionActionInterface::EDIT, $node->getStatus());
- Create a ticketCreate a ticket
- Exclude checks
Return type of newAction()
is undeclared type \Symfony\Component\HttpFoundation\Response
Open
public function newAction(Request $request, $siteId, $language, $parentId, $order)
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::generateUrl
Open
$url = $this->generateUrl('open_orchestra_backoffice_node_form', array(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getStatus
from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open
$form = $this->createForm('oo_node', $node, $options, ContributionActionInterface::EDIT, $node->getStatus());
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$this->get('session')->getFlashBag()->add('success', $message);
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$nodeRepository = $this->get('open_orchestra_model.repository.node');
- Create a ticketCreate a ticket
- Exclude checks
Call to undeclared method \OpenOrchestra\BackofficeBundle\Controller\NodeController::get
Open
$languages = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteLanguages();
- Create a ticketCreate a ticket
- Exclude checks
Call to method __construct
from undeclared class \OpenOrchestra\ModelInterface\Event\NodeEvent
Open
$nodesEvent[] = new NodeEvent($translatedNode);
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $node),
- Create a ticketCreate a ticket
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
public function createForm($type, $data = null, array $options = array(), $editionRole = null, StatusInterface $status = null)
- Create a ticketCreate a ticket
- Exclude checks