Passed
Push — master ( 2d5d29...0740c8 )
by ReliQ
04:50 queued 13s
created

TemplateConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 8
dl 0
loc 18
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 ReliqArts\Docweaver\Model;
6
7
class TemplateConfig
8
{
9
    /**
10
     * @var string
11
     */
12
    private string $masterTemplate;
13
14
    /**
15
     * @var string
16
     */
17
    private string $masterSection;
18
19
    /**
20
     * @var string
21
     */
22
    private string $styleStack;
23
24
    /**
25
     * @var string
26
     */
27
    private string $scriptStack;
28
29
    /**
30
     * @var string
31
     */
32
    private string $indexTitle;
33
34
    /**
35
     * @var string
36
     */
37
    private string $indexIntro;
38
39
    /**
40
     * @var bool
41
     */
42
    private bool $showProductLine;
43
44
    /**
45
     * @var bool
46
     */
47
    private bool $showFootnotes;
48
49
    /**
50
     * TemplateConfig constructor.
51
     */
52
    public function __construct(
53
        string $masterTemplate,
54
        string $masterSection,
55
        string $styleStack,
56
        string $scriptStack,
57
        string $indexTitle,
58
        string $indexIntro,
59
        bool $showProductLine = true,
60
        bool $showFootnotes = true
61
    ) {
62
        $this->masterTemplate = $masterTemplate;
63
        $this->masterSection = $masterSection;
64
        $this->styleStack = $styleStack;
65
        $this->scriptStack = $scriptStack;
66
        $this->indexTitle = $indexTitle;
67
        $this->indexIntro = $indexIntro;
68
        $this->showProductLine = $showProductLine;
69
        $this->showFootnotes = $showFootnotes;
70
    }
71
72
    public function getMasterTemplate(): string
73
    {
74
        return $this->masterTemplate;
75
    }
76
77
    public function getMasterSection(): string
78
    {
79
        return $this->masterSection;
80
    }
81
82
    public function getStyleStack(): string
83
    {
84
        return $this->styleStack;
85
    }
86
87
    public function hasStyleStack(): bool
88
    {
89
        return !empty($this->getStyleStack());
90
    }
91
92
    public function getScriptStack(): string
93
    {
94
        return $this->scriptStack;
95
    }
96
97
    public function hasScriptStack(): bool
98
    {
99
        return !empty($this->getScriptStack());
100
    }
101
102
    public function getIndexTitle(): string
103
    {
104
        return $this->indexTitle;
105
    }
106
107
    public function getIndexIntro(): string
108
    {
109
        return $this->indexIntro;
110
    }
111
112
    public function isShowProductLine(): bool
113
    {
114
        return $this->showProductLine;
115
    }
116
117
    public function isShowFootnotes(): bool
118
    {
119
        return $this->showFootnotes;
120
    }
121
}
122