BuildResponseEvent::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Event;
6
7
use Psr\EventDispatcher\StoppableEventInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
11
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
12
13
final class BuildResponseEvent extends AbstractEvent implements StoppableEventInterface
14
{
15
    private ?ResponseInterface $response = null;
16
17
    public function __construct(
18
        private SiteInterface $site,
19
        private ServerRequestInterface $request,
20
        private SiteLanguage $selectedLanguage
21
    ) {}
22
23
    public function getSite(): SiteInterface
24
    {
25
        return $this->site;
26
    }
27
28
    public function getRequest(): ServerRequestInterface
29
    {
30
        return $this->request;
31
    }
32
33
    public function getSelectedLanguage(): SiteLanguage
34
    {
35
        return $this->selectedLanguage;
36
    }
37
38
    public function getResponse(): ?ResponseInterface
39
    {
40
        return $this->response;
41
    }
42
43
    public function setResponse(ResponseInterface $response): void
44
    {
45
        $this->response = $response;
46
    }
47
48
    public function isPropagationStopped(): bool
49
    {
50
        return $this->getResponse() !== null;
51
    }
52
}
53