CheckLanguageDetectionEvent   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isPropagationStopped() 0 3 1
A disableLanguageDetection() 0 3 1
A __construct() 0 4 1
A getRequest() 0 3 1
A getSite() 0 3 1
A isLanguageDetectionEnable() 0 3 1
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\ServerRequestInterface;
9
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
10
11
final class CheckLanguageDetectionEvent extends AbstractEvent implements StoppableEventInterface
12
{
13
    private bool $handle = true;
14
15
    public function __construct(
16
        private SiteInterface $site,
17
        private ServerRequestInterface $request
18
    ) {}
19
20
    public function getSite(): SiteInterface
21
    {
22
        return $this->site;
23
    }
24
25
    public function getRequest(): ServerRequestInterface
26
    {
27
        return $this->request;
28
    }
29
30
    public function isLanguageDetectionEnable(): bool
31
    {
32
        return $this->handle;
33
    }
34
35
    public function disableLanguageDetection(): void
36
    {
37
        $this->handle = false;
38
    }
39
40
    public function isPropagationStopped(): bool
41
    {
42
        return !$this->isLanguageDetectionEnable();
43
    }
44
}
45