GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FormBuilder::createForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Form\Builder;
6
7
use eZ\Publish\API\Repository\ContentTypeService;
8
use eZ\Publish\API\Repository\Values\Content\Content;
9
use Netgen\InformationCollection\API\Form\DynamicFormBuilderInterface;
10
use Netgen\InformationCollection\Integration\RepositoryForms\InformationCollectionMapper;
11
use Netgen\InformationCollection\Integration\RepositoryForms\InformationCollectionType;
12
use Symfony\Component\Form\FormBuilderInterface;
13
use Symfony\Component\Form\FormFactoryInterface;
14
use Symfony\Component\Form\FormInterface;
15
use Symfony\Component\Routing\RouterInterface;
16
17
class FormBuilder implements DynamicFormBuilderInterface
18
{
19
    /**
20
     * @var FormFactoryInterface
21
     */
22
    protected $formFactory;
23
24
    /**
25
     * @var bool
26
     */
27
    protected $useCsrf;
28
29
    /**
30
     * @var ContentTypeService
31
     */
32
    protected $contentTypeService;
33
34
    /**
35
     * @var RouterInterface
36
     */
37
    protected $router;
38
39
    /**
40
     * FormBuilder constructor.
41
     *
42
     * @param FormFactoryInterface $formFactory
43
     * @param ContentTypeService $contentTypeService
44
     */
45
    public function __construct(FormFactoryInterface $formFactory, ContentTypeService $contentTypeService)
46
    {
47
        $this->formFactory = $formFactory;
48
        $this->contentTypeService = $contentTypeService;
49
    }
50
51
    public function createFormWithAjax(Content $content): FormInterface
52
    {
53
        throw new \RuntimeException('This method is not implemented.');
54
    }
55
56
    public function createForm(Content $content): FormInterface
57
    {
58
        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
59
60
        $informationCollectionMapper = new InformationCollectionMapper();
61
62
        $data = $informationCollectionMapper->mapToFormData($content, $contentType);
63
64
        return $this->formFactory->create(InformationCollectionType::class, $data, [
65
            'languageCode' => $content->contentInfo->mainLanguageCode,
66
            'mainLanguageCode' => $content->contentInfo->mainLanguageCode,
67
        ]);
68
    }
69
}
70