Conditions | 15 |
Paths | 1632 |
Total Lines | 79 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
156 | public function normalizeMetaBundleData(bool $parse = true) |
||
157 | { |
||
158 | // Decode any JSON data |
||
159 | $properties = $this->getAttributes(); |
||
160 | foreach ($properties as $property => $value) { |
||
161 | if (!empty($value) && is_string($value)) { |
||
162 | $this->$property = JsonHelper::decodeIfJson($value); |
||
163 | } |
||
164 | } |
||
165 | // Meta global variables |
||
166 | if (is_array($this->metaGlobalVars)) { |
||
167 | $this->metaGlobalVars = MetaGlobalVars::create($this->metaGlobalVars); |
||
168 | } |
||
169 | // Meta site variables |
||
170 | if (is_array($this->metaSiteVars)) { |
||
171 | $this->metaSiteVars = MetaSiteVars::create($this->metaSiteVars); |
||
172 | } |
||
173 | // Meta sitemap variables |
||
174 | if (is_array($this->metaSitemapVars)) { |
||
175 | $this->metaSitemapVars = MetaSitemapVars::create($this->metaSitemapVars); |
||
176 | } |
||
177 | // Meta bundle settings |
||
178 | if (is_array($this->metaBundleSettings)) { |
||
179 | $this->metaBundleSettings = MetaBundleSettings::create($this->metaBundleSettings); |
||
180 | } |
||
181 | // Frontend templates |
||
182 | if (is_array($this->frontendTemplatesContainer)) { |
||
183 | $this->frontendTemplatesContainer = FrontendTemplateContainer::create($this->frontendTemplatesContainer); |
||
184 | } |
||
185 | // Create our variable so that meta containers can be parsed based on dynamic values |
||
186 | // Make sure Twig is loaded and instantiated first by priming the pump |
||
187 | if ($parse) { |
||
188 | MetaValueHelper::parseString('{{ "prime" }}'); |
||
189 | $oldSeomaticVariable = Seomatic::$seomaticVariable; |
||
190 | if (Seomatic::$seomaticVariable === null) { |
||
191 | Seomatic::$seomaticVariable = new SeomaticVariable(); |
||
192 | } |
||
193 | $oldMeta = Seomatic::$seomaticVariable->meta; |
||
194 | $oldSite = Seomatic::$seomaticVariable->site; |
||
195 | $oldLoadingContainers = Seomatic::$loadingMetaContainers; |
||
196 | $oldPreviewingMetaContainers = Seomatic::$previewingMetaContainers; |
||
197 | Seomatic::$loadingMetaContainers = false; |
||
198 | Seomatic::$previewingMetaContainers = false; |
||
199 | // Merge these global vars with the MetaContainers global vars |
||
200 | $globalVars = []; |
||
201 | if (Seomatic::$plugin->metaContainers->metaGlobalVars !== null) { |
||
202 | $globalVars = Seomatic::$plugin->metaContainers->metaGlobalVars->getAttributes(); |
||
203 | } |
||
204 | $thisGlobalVars = $this->metaGlobalVars->getAttributes(); |
||
|
|||
205 | $thisGlobals = MetaGlobalVars::create(ArrayHelper::merge($globalVars, $thisGlobalVars)); |
||
206 | // Merge these site vars with the MetaContainers site vars |
||
207 | $siteVars = []; |
||
208 | if (Seomatic::$plugin->metaContainers->metaSiteVars !== null) { |
||
209 | $siteVars = Seomatic::$plugin->metaContainers->metaSiteVars->getAttributes(); |
||
210 | } |
||
211 | $thisSiteVars = $this->metaSiteVars->getAttributes(); |
||
212 | $thisSite = MetaSiteVars::create(ArrayHelper::merge($siteVars, $thisSiteVars)); |
||
213 | Seomatic::$seomaticVariable->meta = $thisGlobals; |
||
214 | Seomatic::$seomaticVariable->site = $thisSite; |
||
215 | MetaValueHelper::cache(); |
||
216 | Seomatic::$previewingMetaContainers = $oldPreviewingMetaContainers; |
||
217 | |||
218 | // Meta containers |
||
219 | if (!empty($this->metaContainers)) { |
||
220 | $metaContainers = $this->metaContainers; |
||
221 | $this->metaContainers = []; |
||
222 | foreach ($metaContainers as $key => $metaContainer) { |
||
223 | /** @var MetaContainer $containerClass */ |
||
224 | $containerClass = $metaContainer['class']; |
||
225 | /** @var array $metaContainer */ |
||
226 | $this->metaContainers[$key] = $containerClass::create($metaContainer); |
||
227 | } |
||
228 | } |
||
229 | // Restore the $seomaticVariable |
||
230 | Seomatic::$loadingMetaContainers = $oldLoadingContainers; |
||
231 | Seomatic::$seomaticVariable->meta = $oldMeta; |
||
232 | Seomatic::$seomaticVariable->site = $oldSite; |
||
233 | Seomatic::$seomaticVariable = $oldSeomaticVariable; |
||
234 | MetaValueHelper::cache(); |
||
235 | } |
||
326 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.