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.
Completed
Pull Request — master (#73)
by
unknown
14:32
created

Handler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 7
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getForm() 0 13 1
A handle() 0 6 1
1
<?php
2
3
namespace Netgen\InformationCollection;
4
5
use eZ\Publish\API\Repository\ContentTypeService;
6
use eZ\Publish\API\Repository\Values\Content\Content;
7
use eZ\Publish\API\Repository\Values\Content\Location;
8
use Netgen\InformationCollection\API\Events;
9
use Netgen\InformationCollection\API\Value\Event\InformationCollected;
10
use Netgen\InformationCollection\API\Value\InformationCollectionStruct;
11
use Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionMapper;
12
use Netgen\Bundle\InformationCollectionBundle\EzPlatform\RepositoryForms\InformationCollectionType;
13
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
14
use Symfony\Component\Form\FormFactoryInterface;
15
use Symfony\Component\Form\FormInterface;
16
17
final class Handler
18
{
19
    /**
20
     * @var \Symfony\Component\Form\FormFactoryInterface
21
     */
22
    private $formFactory;
23
24
    /**
25
     * @var \eZ\Publish\API\Repository\ContentTypeService
26
     */
27
    private $contentTypeService;
28
29
    /**
30
     * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
31
     */
32
    private $eventDispatcher;
33
34
    public function __construct(FormFactoryInterface $formFactory, ContentTypeService $contentTypeService, EventDispatcherInterface $eventDispatcher)
35
    {
36
        $this->formFactory = $formFactory;
37
        $this->contentTypeService = $contentTypeService;
38
        $this->eventDispatcher = $eventDispatcher;
39
    }
40
41
    public function getForm(Content $content, Location $location): FormInterface
42
    {
43
        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
44
45
        $informationCollectionMapper = new InformationCollectionMapper();
46
47
        $data = $informationCollectionMapper->mapToFormData($content, $location, $contentType);
48
49
        return $this->formFactory->create(InformationCollectionType::class, $data, [
50
            'languageCode' => $content->contentInfo->mainLanguageCode,
51
            'mainLanguageCode' => $content->contentInfo->mainLanguageCode,
52
        ]);
53
    }
54
55
    public function handle(InformationCollectionStruct $struct, array $options): void
56
    {
57
        $event = new InformationCollected($struct, $options);
58
59
        $this->eventDispatcher->dispatch($event, Events::INFORMATION_COLLECTED);
0 ignored issues
show
Documentation introduced by
$event is of type object<Netgen\Informatio...t\InformationCollected>, but the function expects a object<Symfony\Contracts\EventDispatcher\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
    }
61
}
62