Conditions | 33 |
Paths | > 20000 |
Total Lines | 102 |
Code Lines | 62 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
75 | public function getFieldConfig(string $class): array |
||
76 | { |
||
77 | $config = []; |
||
78 | |||
79 | if ($this->containerTag !== null) { |
||
80 | $config['containerTag()'] = [$this->containerTag]; |
||
81 | } |
||
82 | if ($this->containerAttributes !== []) { |
||
83 | $config['containerAttributes()'] = [$this->containerAttributes]; |
||
84 | } |
||
85 | if ($this->containerClass !== null) { |
||
86 | $config['containerClass()'] = is_array($this->containerClass) |
||
87 | ? $this->containerClass |
||
88 | : [$this->containerClass]; |
||
89 | } |
||
90 | if ($this->useContainer !== null) { |
||
91 | $config['useContainer()'] = [$this->useContainer]; |
||
92 | } |
||
93 | |||
94 | if (is_a($class, PartsField::class, true)) { |
||
95 | if ($this->template !== null) { |
||
96 | $config['template()'] = [$this->template]; |
||
97 | } |
||
98 | if ($this->templateBegin !== null) { |
||
99 | $config['templateBegin()'] = [$this->templateBegin]; |
||
100 | } |
||
101 | if ($this->templateEnd !== null) { |
||
102 | $config['templateEnd()'] = [$this->templateEnd]; |
||
103 | } |
||
104 | if ($this->inputContainerTag !== null) { |
||
105 | $config['inputContainerTag()'] = [$this->inputContainerTag]; |
||
106 | } |
||
107 | if ($this->inputContainerAttributes !== []) { |
||
108 | $config['inputContainerAttributes()'] = [$this->inputContainerAttributes]; |
||
109 | } |
||
110 | if ($this->inputContainerClass !== null) { |
||
111 | $config['inputContainerClass()'] = is_array($this->inputContainerClass) |
||
112 | ? $this->inputContainerClass |
||
113 | : [$this->inputContainerClass]; |
||
114 | } |
||
115 | if ($this->labelConfig !== []) { |
||
116 | $config['labelConfig()'] = [$this->labelConfig]; |
||
117 | } |
||
118 | if ($this->hintConfig !== []) { |
||
119 | $config['hintConfig()'] = [$this->hintConfig]; |
||
120 | } |
||
121 | if ($this->errorConfig !== []) { |
||
122 | $config['errorConfig()'] = [$this->errorConfig]; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | if (is_a($class, InputField::class, true)) { |
||
127 | if ($this->setInputId !== null) { |
||
128 | $config['setInputId()'] = [$this->setInputId]; |
||
129 | if ($this->setInputId === false) { |
||
130 | $config['labelConfig()'] = [ |
||
131 | $this->labelConfig + ['useInputId()' => [false]], |
||
132 | ]; |
||
133 | } |
||
134 | } |
||
135 | if ($this->inputAttributes !== []) { |
||
136 | $config['inputAttributes()'] = [$this->inputAttributes]; |
||
137 | } |
||
138 | if ($this->inputClass !== null) { |
||
139 | $config['inputClass()'] = is_array($this->inputClass) |
||
140 | ? $this->inputClass |
||
141 | : [$this->inputClass]; |
||
142 | } |
||
143 | } |
||
144 | |||
145 | if (is_a($class, PlaceholderInterface::class, true)) { |
||
146 | if ($this->usePlaceholder !== null) { |
||
147 | $config['usePlaceholder()'] = [$this->usePlaceholder]; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | if (is_a($class, EnrichmentFromRulesInterface::class, true)) { |
||
152 | if ($this->enrichmentFromRules !== null) { |
||
153 | $config['enrichmentFromRules()'] = [$this->enrichmentFromRules]; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | if (is_a($class, ValidationClassInterface::class, true)) { |
||
158 | if ($this->validClass !== null) { |
||
159 | $config['validClass()'] = [$this->validClass]; |
||
160 | } |
||
161 | if ($this->invalidClass !== null) { |
||
162 | $config['invalidClass()'] = [$this->invalidClass]; |
||
163 | } |
||
164 | if ($this->inputValidClass !== null) { |
||
165 | $config['inputValidClass()'] = [$this->inputValidClass]; |
||
166 | } |
||
167 | if ($this->inputInvalidClass !== null) { |
||
168 | $config['inputInvalidClass()'] = [$this->inputInvalidClass]; |
||
169 | } |
||
170 | } |
||
171 | |||
172 | if (!empty($this->fieldConfigs[$class])) { |
||
173 | $config = array_merge($config, $this->fieldConfigs[$class]); |
||
174 | } |
||
175 | |||
176 | return $config; |
||
177 | } |
||
179 |