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

SiteConfigurationService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 14
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 12 3
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