Passed
Push — main ( 656e89...66a587 )
by Tim
06:34 queued 03:15
created

AbstractHandler::getSiteFromRequest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Handler;
6
7
use Psr\EventDispatcher\EventDispatcherInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
10
11
abstract class AbstractHandler
12
{
13
    protected EventDispatcherInterface $eventDispatcher;
14
15
    public function __construct(EventDispatcherInterface $eventDispatcher)
16
    {
17
        $this->eventDispatcher = $eventDispatcher;
18
    }
19
20
    protected function getSiteFromRequest(ServerRequestInterface $request): SiteInterface
21
    {
22
        $site = $request->getAttribute('site');
23
        if (!($site instanceof SiteInterface)) {
24
            throw new \Exception('Found no valid site object in request', 1_637_813_123);
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting ',' or ')' on line 24 at column 75
Loading history...
25
        }
26
27
        return $site;
28
    }
29
}
30