Passed
Push — main ( b4ea3d...ecbac5 )
by Tim
13:33
created

SiteConfiguration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 11
dl 0
loc 24
rs 9.9
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lochmueller\LanguageDetection\Domain\Model\Dto;
6
7
class SiteConfiguration
8
{
9
    protected bool $enableLanguageDetection;
10
11
    protected bool $disableRedirectWithBackendSession;
12
13
    protected string $addIpLocationToBrowserLanguage;
14
15
    protected bool $allowAllPaths;
16
17
    protected int $redirectHttpStatusCode;
18
19
    protected string $forwardRedirectParameters;
20
21
    protected int $fallbackDetectionLanguage;
22
23
    protected string $maxMindDatabasePath;
24
25
    protected int $maxMindAccountId;
26
27
    protected string $maxMindLicenseKey;
28
29
    protected string $maxMindMode;
30
31
    public function __construct(
32
        bool $enableLanguageDetection,
33
        bool $disableRedirectWithBackendSession,
34
        string $addIpLocationToBrowserLanguage,
35
        bool $allowAllPaths,
36
        int $redirectHttpStatusCode,
37
        string $forwardRedirectParameters,
38
        int $fallbackDetectionLanguage,
39
        string $maxMindDatabasePath,
40
        int $maxMindAccountId,
41
        string $maxMindLicenseKey,
42
        string $maxMindMode
43
    ) {
44
        $this->enableLanguageDetection = $enableLanguageDetection;
45
        $this->disableRedirectWithBackendSession = $disableRedirectWithBackendSession;
46
        $this->addIpLocationToBrowserLanguage = $addIpLocationToBrowserLanguage;
47
        $this->allowAllPaths = $allowAllPaths;
48
        $this->redirectHttpStatusCode = $redirectHttpStatusCode;
49
        $this->forwardRedirectParameters = $forwardRedirectParameters;
50
        $this->fallbackDetectionLanguage = $fallbackDetectionLanguage;
51
        $this->maxMindDatabasePath = $maxMindDatabasePath;
52
        $this->maxMindAccountId = $maxMindAccountId;
53
        $this->maxMindLicenseKey = $maxMindLicenseKey;
54
        $this->maxMindMode = $maxMindMode;
55
    }
56
57
    public function isEnableLanguageDetection(): bool
58
    {
59
        return $this->enableLanguageDetection;
60
    }
61
62
    public function isDisableRedirectWithBackendSession(): bool
63
    {
64
        return $this->disableRedirectWithBackendSession;
65
    }
66
67
    public function getAddIpLocationToBrowserLanguage(): string
68
    {
69
        return $this->addIpLocationToBrowserLanguage;
70
    }
71
72
    public function isAllowAllPaths(): bool
73
    {
74
        return $this->allowAllPaths;
75
    }
76
77
    public function getRedirectHttpStatusCode(): int
78
    {
79
        return $this->redirectHttpStatusCode;
80
    }
81
82
    public function getForwardRedirectParameters(): string
83
    {
84
        return $this->forwardRedirectParameters;
85
    }
86
87
    public function getFallbackDetectionLanguage(): int
88
    {
89
        return $this->fallbackDetectionLanguage;
90
    }
91
92
    public function getMaxMindDatabasePath(): string
93
    {
94
        return $this->maxMindDatabasePath;
95
    }
96
97
    public function getMaxMindAccountId(): int
98
    {
99
        return $this->maxMindAccountId;
100
    }
101
102
    public function getMaxMindLicenseKey(): string
103
    {
104
        return $this->maxMindLicenseKey;
105
    }
106
107
    public function getMaxMindMode(): string
108
    {
109
        return $this->maxMindMode;
110
    }
111
}
112