Completed
Push — master ( 2df7ac...02da02 )
by De Cramer
19s queued 11s
created

SelectFormProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addTypeToForm() 0 17 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
        $formBuilder->add(
26
            $name,
27
            $this->formType,
28
            [
29
                'label' => $config->getName(),
30
                'help' => $this->getHelpHtml($config, $scope),
31
                'data' => $config->get($scope),
32
                'choices'  => $config->getOptions(),
33
                'multiple' => $config->isAllowMultiple(),
34
            ],
35
        );
36
    }
37
}
38