Code Duplication    Length = 35-35 lines in 2 locations

src/Integrations/Symfony/EventSubscribers/AddsRequestIdOnRequest.php 1 location

@@ 16-50 (lines=35) @@
13
/**
14
 * Adds request ID on requests
15
 */
16
final class AddsRequestIdOnRequest implements EventSubscriberInterface
17
{
18
    /**
19
     * @var RequestDecorator
20
     */
21
    private $decorator;
22
23
    /**
24
     * @param RequestDecorator $decorator
25
     */
26
    public function __construct(RequestDecorator $decorator)
27
    {
28
        $this->decorator = $decorator;
29
    }
30
31
    /**
32
     * @param GetResponseEvent $event
33
     */
34
    public function onRequest(GetResponseEvent $event)
35
    {
36
        if (!$event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
37
            return;
38
        }
39
40
        $this->decorator->decorateRequest($event->getRequest());
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public static function getSubscribedEvents()
47
    {
48
        return [KernelEvents::REQUEST => ['onRequest', 200]];
49
    }
50
}
51

src/Integrations/Symfony/EventSubscribers/AddsRequestIdOnResponse.php 1 location

@@ 15-49 (lines=35) @@
12
/**
13
 * Adds request ID on responses
14
 */
15
final class AddsRequestIdOnResponse implements EventSubscriberInterface
16
{
17
    /**
18
     * @var ResponseDecorator
19
     */
20
    private $decorator;
21
22
    /**
23
     * @param ResponseDecorator $decorator
24
     */
25
    public function __construct(ResponseDecorator $decorator)
26
    {
27
        $this->decorator = $decorator;
28
    }
29
30
    /**
31
     * @param FilterResponseEvent $event
32
     */
33
    public function onResponse(FilterResponseEvent $event)
34
    {
35
        if (!$event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
36
            return;
37
        }
38
39
        $this->decorator->decorateResponse($event->getResponse());
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public static function getSubscribedEvents()
46
    {
47
        return [KernelEvents::RESPONSE => ['onResponse', -200]];
48
    }
49
}
50