Handler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleRequest() 0 12 3
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Admin\Display\Context\Request;
13
14
use FSi\Bundle\AdminBundle\Admin\Context\Request\AbstractHandler;
15
use FSi\Bundle\AdminBundle\Event\AdminEvent;
16
use FSi\Bundle\AdminBundle\Event\DisplayEvent;
17
use FSi\Bundle\AdminBundle\Event\DisplayEvents;
18
use FSi\Bundle\AdminBundle\Exception\RequestHandlerException;
19
use Symfony\Component\HttpFoundation\Request;
20
use Symfony\Component\HttpFoundation\Response;
21
22
class Handler extends AbstractHandler
23
{
24
    /**
25
     * @param AdminEvent $event
26
     * @param Request $request
27
     * @return Response|null
28
     * @throws RequestHandlerException
29
     */
30
    public function handleRequest(AdminEvent $event, Request $request): ?Response
31
    {
32
        if (!$event instanceof DisplayEvent) {
33
            throw new RequestHandlerException(sprintf('%s requires DisplayEvent', get_class($this)));
34
        }
35
36
        $this->eventDispatcher->dispatch(DisplayEvents::DISPLAY_PRE_RENDER, $event);
0 ignored issues
show
Bug introduced by
FSi\Bundle\AdminBundle\E...nts::DISPLAY_PRE_RENDER of type string is incompatible with the type object expected by parameter $event of Symfony\Contracts\EventD...erInterface::dispatch(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $this->eventDispatcher->dispatch(/** @scrutinizer ignore-type */ DisplayEvents::DISPLAY_PRE_RENDER, $event);
Loading history...
Unused Code introduced by
The call to Symfony\Contracts\EventD...erInterface::dispatch() has too many arguments starting with $event. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $this->eventDispatcher->/** @scrutinizer ignore-call */ 
37
                                dispatch(DisplayEvents::DISPLAY_PRE_RENDER, $event);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
37
        if ($event->hasResponse()) {
38
            return $event->getResponse();
39
        }
40
41
        return null;
42
    }
43
}
44