Passed
Push — master ( f1e8a4...0fff4f )
by De Cramer
07:22
created

JsonFormProvider::formatData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace oliverde8\ComfyBundle\Resolver\Form;
4
5
use oliverde8\ComfyBundle\Model\ConfigInterface;
6
use Symfony\Component\Form\FormBuilderInterface;
7
8
class JsonFormProvider extends SimpleFormProvider
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function addTypeToForm(string $name, ConfigInterface $config, FormBuilderInterface $formBuilder, string $scope)
14
    {
15
        $formBuilder->add(
16
            $name,
17
            $this->formType,
18
            [
19
                'label' => $config->getName(),
20
                'data' => json_encode($config->get($scope), JSON_PRETTY_PRINT),
21
            ],
22
        );
23
    }
24
25
    public function formatData($data)
26
    {
27
        return json_decode($data, true);
28
    }
29
}
30