Passed
Pull Request — master (#159)
by Alexander
04:51 queued 02:29
created

FieldFactoryConfig::useContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Form;
6
7
final class FieldFactoryConfig
8
{
9
    //
10
    // Common
11
    //
12
13
    private ?string $containerTag = null;
14
    private array $containerTagAttributes = [];
15
    private ?bool $useContainer = null;
16
17
    private ?string $template = null;
18
19
    private ?bool $setInputIdAttribute = null;
20
21
    private array $formElementTagAttributes = [];
22
23
    private array $labelConfig = [];
24
    private array $hintConfig = [];
25
    private array $errorConfig = [];
26
27
    //
28
    // Placeholder
29
    //
30
31
    private ?bool $usePlaceholder = null;
32
33
    //
34
    // Field configurations
35
    //
36
37
    private array $fieldConfigs = [];
38
39 2
    public function containerTag(?string $tag): self
40
    {
41 2
        $new = clone $this;
42 2
        $new->containerTag = $tag;
43 2
        return $new;
44
    }
45
46 2
    public function containerTagAttributes(array $attributes): self
47
    {
48 2
        $new = clone $this;
49 2
        $new->containerTagAttributes = $attributes;
50 2
        return $new;
51
    }
52
53 1
    public function useContainer(?bool $use): self
54
    {
55 1
        $new = clone $this;
56 1
        $new->useContainer = $use;
57 1
        return $new;
58
    }
59
60 1
    public function template(?string $template): self
61
    {
62 1
        $new = clone $this;
63 1
        $new->template = $template;
64 1
        return $new;
65
    }
66
67 2
    public function setInputIdAttribute(?bool $value): self
68
    {
69 2
        $new = clone $this;
70 2
        $new->setInputIdAttribute = $value;
71 2
        return $new;
72
    }
73
74 2
    public function formElementTagAttributes(array $attributes): self
75
    {
76 2
        $new = clone $this;
77 2
        $new->formElementTagAttributes = $attributes;
78 2
        return $new;
79
    }
80
81 2
    public function labelConfig(array $config): self
82
    {
83 2
        $new = clone $this;
84 2
        $new->labelConfig = $config;
85 2
        return $new;
86
    }
87
88 2
    public function hintConfig(array $config): self
89
    {
90 2
        $new = clone $this;
91 2
        $new->hintConfig = $config;
92 2
        return $new;
93
    }
94
95 2
    public function errorConfig(array $config): self
96
    {
97 2
        $new = clone $this;
98 2
        $new->errorConfig = $config;
99 2
        return $new;
100
    }
101
102 2
    public function usePlaceholder(?bool $use): self
103
    {
104 2
        $new = clone $this;
105 2
        $new->usePlaceholder = $use;
106 2
        return $new;
107
    }
108
109 1
    public function addFieldConfigs(array $configs): self
110
    {
111 1
        $new = clone $this;
112 1
        $new->fieldConfigs = array_merge($this->fieldConfigs, $configs);
113 1
        return $new;
114
    }
115
116 24
    public function getContainerTag(): ?string
117
    {
118 24
        return $this->containerTag;
119
    }
120
121 24
    public function getContainerTagAttributes(): array
122
    {
123 24
        return $this->containerTagAttributes;
124
    }
125
126 24
    public function getUseContainer(): ?bool
127
    {
128 24
        return $this->useContainer;
129
    }
130
131 24
    public function getTemplate(): ?string
132
    {
133 24
        return $this->template;
134
    }
135
136 24
    public function getSetInputIdAttribute(): ?bool
137
    {
138 24
        return $this->setInputIdAttribute;
139
    }
140
141 24
    public function getFormElementTagAttributes(): array
142
    {
143 24
        return $this->formElementTagAttributes;
144
    }
145
146 24
    public function getLabelConfig(): array
147
    {
148 24
        return $this->labelConfig;
149
    }
150
151 24
    public function getHintConfig(): array
152
    {
153 24
        return $this->hintConfig;
154
    }
155
156 24
    public function getErrorConfig(): array
157
    {
158 24
        return $this->errorConfig;
159
    }
160
161 24
    public function getUsePlaceholder(): ?bool
162
    {
163 24
        return $this->usePlaceholder;
164
    }
165
166 24
    public function getFieldConfigs(): array
167
    {
168 24
        return $this->fieldConfigs;
169
    }
170
}
171