SiteConfiguration::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 11
dl 0
loc 13
rs 10
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
    public function __construct(
10
        protected bool $enableLanguageDetection,
11
        protected bool $disableRedirectWithBackendSession,
12
        protected string $addIpLocationToBrowserLanguage,
13
        protected bool $allowAllPaths,
14
        protected int $redirectHttpStatusCode,
15
        protected string $forwardRedirectParameters,
16
        protected int $fallbackDetectionLanguage,
17
        protected string $maxMindDatabasePath,
18
        protected int $maxMindAccountId,
19
        protected string $maxMindLicenseKey,
20
        protected string $maxMindMode
21
    ) {}
22
23
    public function isEnableLanguageDetection(): bool
24
    {
25
        return $this->enableLanguageDetection;
26
    }
27
28
    public function isDisableRedirectWithBackendSession(): bool
29
    {
30
        return $this->disableRedirectWithBackendSession;
31
    }
32
33
    public function getAddIpLocationToBrowserLanguage(): string
34
    {
35
        return $this->addIpLocationToBrowserLanguage;
36
    }
37
38
    public function isAllowAllPaths(): bool
39
    {
40
        return $this->allowAllPaths;
41
    }
42
43
    public function getRedirectHttpStatusCode(): int
44
    {
45
        return $this->redirectHttpStatusCode;
46
    }
47
48
    public function getForwardRedirectParameters(): string
49
    {
50
        return $this->forwardRedirectParameters;
51
    }
52
53
    public function getFallbackDetectionLanguage(): int
54
    {
55
        return $this->fallbackDetectionLanguage;
56
    }
57
58
    public function getMaxMindDatabasePath(): string
59
    {
60
        return $this->maxMindDatabasePath;
61
    }
62
63
    public function getMaxMindAccountId(): int
64
    {
65
        return $this->maxMindAccountId;
66
    }
67
68
    public function getMaxMindLicenseKey(): string
69
    {
70
        return $this->maxMindLicenseKey;
71
    }
72
73
    public function getMaxMindMode(): string
74
    {
75
        return $this->maxMindMode;
76
    }
77
}
78