Passed
Pull Request — master (#1)
by De Cramer
08:09
created

SelectFormProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addTypeToForm() 0 18 2
1
<?php
2
3
4
namespace oliverde8\ComfyBundle\Resolver\Form;
5
6
7
use oliverde8\ComfyBundle\Exception\InvalidConfigTypeForFormProvider;
8
use oliverde8\ComfyBundle\Model\ConfigInterface;
9
use oliverde8\ComfyBundle\Model\SelectConfig;
10
use Symfony\Component\Form\FormInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\FormInterface 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...
11
12
class SelectFormProvider extends SimpleFormProvider
13
{
14
    /**
15
     * @inheritdoc
16
     */
17
    public function addTypeToForm(string $name, ConfigInterface $config, FormInterface $formBuilder, string $scope)
18
    {
19
        if (!($config instanceof SelectConfig)) {
20
            throw new InvalidConfigTypeForFormProvider(
21
                sprintf("Config is expected to be of type %s but is of type %s", SelectConfig::class, get_class($config))
22
            );
23
        }
24
25
        dump($config->get($scope));
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
                'choices'  => $config->getOptions(),
34
                'multiple' => $config->isAllowMultiple(),
35
            ],
36
        );
37
    }
38
}
39