open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/EventSubscriber/FieldTypeTypeSubscriber.php

Summary

Maintainability
A
1 hr
Test Coverage

Function addOptionsFormType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addOptionsFormType(FieldTypeInterface $data, $type, FormInterface $form)
    {
        if (is_null($type) || !array_key_exists($type, $this->fieldTypeParameters)) {
            return;
        }
Severity: Minor
Found in Backoffice/EventSubscriber/FieldTypeTypeSubscriber.php - About 1 hr to fix

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

Function addDefaultValueFormType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addDefaultValueFormType(FieldTypeInterface $data, $type, FormInterface $form)
    {
        $container = $form->get('container');

        if ($container->has('default_value')) {
Severity: Minor
Found in Backoffice/EventSubscriber/FieldTypeTypeSubscriber.php - About 25 mins to fix

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

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

            if ($data instanceof FieldTypeInterface) {

Call to method get from undeclared class \Symfony\Component\Form\FormInterface
Open

        $container = $form->get('container');

Call to method getData from undeclared class \Symfony\Component\Form\FormEvent
Open

        $dataSend = $event->getData();

Call to method get from undeclared class \Symfony\Component\Form\FormInterface
Open

        $container = $form->get('options');

Call to method getDefaultValue from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

            $defaultOption['data'] = $data->getDefaultValue();

Parameter $data has undeclared type \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

    protected function addOptionsFormType(FieldTypeInterface $data, $type, FormInterface $form)

Call to method getForm from undeclared class \Symfony\Component\Form\FormEvent
Open

        $form = $event->getForm();

Parameter $form has undeclared type \Symfony\Component\Form\FormInterface
Open

    protected function addDefaultValueFormType(FieldTypeInterface $data, $type, FormInterface $form)

Reference to constant PRE_SUBMIT from undeclared class \Symfony\Component\Form\FormEvents
Open

            FormEvents::PRE_SUBMIT => 'preSubmit',

Call to method setFieldTypeSearchable from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

            $data->setFieldTypeSearchable($this->fieldTypeParameters[$type]['search']);

Call to method __construct from undeclared class \Symfony\Component\Validator\Constraints\NotBlank
Open

            $formTypeOptions['constraints'] = new NotBlank();

Parameter $form has undeclared type \Symfony\Component\Form\FormInterface
Open

    protected function addOptionFormType(FormInterface $form, $child, $data) {

Call to method getForm from undeclared class \Symfony\Component\Form\FormEvent
Open

        $form = $event->getForm();

Reference to constant PRE_SET_DATA from undeclared class \Symfony\Component\Form\FormEvents
Open

            FormEvents::PRE_SET_DATA => 'preSetData',

Call to method getType from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

        if ($data->getType() !== $type) {

Call to method setDefaultValue from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

            $data->setDefaultValue(null);

Parameter $event has undeclared type \Symfony\Component\Form\FormEvent
Open

    public function preSetData(FormEvent $event)

Call to method getOptions from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

            foreach ($data->getOptions() as $fieldOption) {

Parameter $event has undeclared type \Symfony\Component\Form\FormEvent
Open

    public function preSubmit(FormEvent $event)

Call to method getForm from undeclared class \Symfony\Component\Form\FormEvent
Open

            $event->getForm()->setData($data);

Call to method add from undeclared class \Symfony\Component\Form\FormInterface
Open

        $form->add($child, $formType, $formTypeOptions);

Class implements undeclared interface \Symfony\Component\EventDispatcher\EventSubscriberInterface
Open

class FieldTypeTypeSubscriber implements EventSubscriberInterface

Call to method getData from undeclared class \Symfony\Component\Form\FormEvent
Open

            $data = $event->getData();

Parameter $form has undeclared type \Symfony\Component\Form\FormInterface
Open

    protected function addOptionsFormType(FieldTypeInterface $data, $type, FormInterface $form)

Call to method getType from undeclared class \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

                $type = $data->getType();

Parameter $data has undeclared type \OpenOrchestra\ModelInterface\Model\FieldTypeInterface
Open

    protected function addDefaultValueFormType(FieldTypeInterface $data, $type, FormInterface $form)

Expected 1 space after "as"; 2 found
Open

        foreach ($container->all() as  $child) {

Opening brace should be on a new line
Open

    protected function addOptionFormType(FormInterface $form, $child, $data) {

There are no issues that match your filters.

Category
Status