Passed
Push — master ( 4d2afb...37b1cc )
by Tim
02:49
created

SiteConfigurationService::getConfiguration()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
nc 2
nop 1
dl 0
loc 12
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LD\LanguageDetection\Service;
6
7
use LD\LanguageDetection\Domain\Model\Dto\SiteConfiguration;
8
use TYPO3\CMS\Core\Site\Entity\Site;
9
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
10
11
class SiteConfigurationService
12
{
13
    public function getConfiguration(SiteInterface $site): SiteConfiguration
14
    {
15
        $config = $site instanceof Site ? $site->getConfiguration() : [];
16
17
        return new SiteConfiguration(
18
            !\array_key_exists('enableLanguageDetection', $config) || (bool)$config['enableLanguageDetection'],
19
            $config['disableRedirectWithBackendSession'] ?? false,
20
            $config['addIpLocationToBrowserLanguage'] ?? '',
21
            $config['allowAllPaths'] ?? '',
22
            $config['redirectHttpStatusCode'] ?? 307,
23
            $config['forwardRedirectParameters'] ?? '',
24
            $config['fallbackDetectionLanguage'] ?? 0,
25
        );
26
    }
27
}
28