Backoffice/EventSubscriber/SortableCollectionSubscriber.php
Function preSubmit
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
public function preSubmit(FormEvent $event)
{
$form = $event->getForm();
$data = $form->getData();
- 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
Call to method getData
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
if (is_array($event->getData())) {
- Create a ticketCreate a ticket
- Exclude checks
Method \OpenOrchestra\Backoffice\EventSubscriber\SortableCollectionSubscriber::preSubmit
is declared to return \Symfony\Component\Form\FormInterface
but has no return value Open
Open
public function preSubmit(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Return type of preSubmit()
is undeclared type \Symfony\Component\Form\FormInterface
Open
Open
public function preSubmit(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method clear
from undeclared class \Doctrine\Common\Collections\Collection
Open
Open
$data->clear();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getForm
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$form = $event->getForm();
- Create a ticketCreate a ticket
- Exclude checks
Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open
Open
class SortableCollectionSubscriber implements EventSubscriberInterface
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \Doctrine\Common\Collections\Collection
Open
Open
if ($data instanceof Collection) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method toArray
from undeclared class \Doctrine\Common\Collections\Collection
Open
Open
$dataClone = $data->toArray();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getData
from undeclared class \Symfony\Component\Form\FormEvent
Open
Open
$order = array_flip(array_keys($event->getData()));
- Create a ticketCreate a ticket
- Exclude checks
Reference to constant PRE_SUBMIT
from undeclared class \Symfony\Component\Form\FormEvents
Open
Open
FormEvents::PRE_SUBMIT => 'preSubmit',
- Create a ticketCreate a ticket
- Exclude checks
Parameter $event
has undeclared type \Symfony\Component\Form\FormEvent
Open
Open
public function preSubmit(FormEvent $event)
- Create a ticketCreate a ticket
- Exclude checks
Call to method set
from undeclared class \Doctrine\Common\Collections\Collection
Open
Open
$data->set($key, array_key_exists($key, $dataClone) ? $dataClone[$key] : null);
- Create a ticketCreate a ticket
- Exclude checks