EntityFormProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addTypeToForm() 0 17 2
1
<?php
2
3
namespace oliverde8\ComfyBundle\Resolver\Form;
4
5
use oliverde8\ComfyBundle\Exception\InvalidConfigTypeForFormProvider;
6
use oliverde8\ComfyBundle\Model\ConfigInterface;
7
use oliverde8\ComfyBundle\Model\EntityConfig;
8
use oliverde8\ComfyBundle\Model\SelectConfig;
9
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
0 ignored issues
show
Bug introduced by
The type Symfony\Bridge\Doctrine\Form\Type\EntityType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\Form\FormInterface;
12
13
class EntityFormProvider extends SimpleFormProvider
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function addTypeToForm(string $name, ConfigInterface $config, FormBuilderInterface $formBuilder, string $scope)
19
    {
20
        if (!($config instanceof EntityConfig)) {
21
            throw new InvalidConfigTypeForFormProvider(
22
                sprintf("Config is expected to be of type %s but is of type %s", SelectConfig::class, get_class($config))
23
            );
24
        }
25
26
        $formBuilder->add(
27
            $name,
28
            $this->formType,
29
            [
30
                'label' => $config->getName(),
31
                'help' => $this->getHelpHtml($config, $scope),
32
                'data' => $config->get($scope),
33
                'class'  => $config->getEntity(),
34
                'choice_label' => $config->getChoiceLabel(),
35
            ],
36
        );
37
    }
38
}
39