Conditions | 18 |
Paths | 21 |
Total Lines | 70 |
Code Lines | 48 |
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 |
||
50 | private function parseXml(SimpleXMLElement $locale) |
||
51 | { |
||
52 | /** @var SimpleXMLElement $node */ |
||
53 | foreach ($locale as $node) { |
||
54 | switch ($node->getName()) { |
||
|
|||
55 | case 'style-options': |
||
56 | $this->optionsXml->put('options', $node); |
||
57 | foreach ($node->attributes() as $name => $value) { |
||
58 | if ((string) $value == 'true') { |
||
59 | $this->options->put($name, [true]); |
||
60 | } else { |
||
61 | $this->options->put($name, [false]); |
||
62 | } |
||
63 | } |
||
64 | break; |
||
65 | case 'terms': |
||
66 | $this->termsXml->put('terms', emptyList()); |
||
67 | $this->termsXml["terms"]->add($node); |
||
68 | $plural = ['single', 'multiple']; |
||
69 | |||
70 | /** @var SimpleXMLElement $child */ |
||
71 | foreach ($node->children() as $child) { |
||
72 | $term = new Term(); |
||
73 | |||
74 | foreach ($child->attributes() as $key => $value) { |
||
75 | $term->{$key} = (string) $value; |
||
76 | } |
||
77 | |||
78 | $subChildren = $child->children(); |
||
79 | $count = $subChildren->count(); |
||
80 | if ($count > 0) { |
||
81 | /** @var SimpleXMLElement $subChild */ |
||
82 | foreach ($subChildren as $subChild) { |
||
83 | $name = $subChild->getName(); |
||
84 | $value = (string) $subChild; |
||
85 | if (in_array($subChild->getName(), $plural)) { |
||
86 | $term->{$name} = $value; |
||
87 | } |
||
88 | } |
||
89 | } else { |
||
90 | $value = (string) $child; |
||
91 | $term->{'single'} = $value; |
||
92 | $term->{'multiple'} = $value; |
||
93 | } |
||
94 | if (!$this->terms->containsKey($term->getName())) { |
||
95 | $this->terms->put($term->getName(), emptyList()); |
||
96 | } |
||
97 | |||
98 | $this->terms[$term->getName()]->add($term); |
||
99 | } |
||
100 | break; |
||
101 | case 'date': |
||
102 | $form = (string) $node["form"]; |
||
103 | $this->dateXml->put($form, $node); |
||
104 | foreach ($node->children() as $child) { |
||
105 | $date = new stdClass(); |
||
106 | $name = ""; |
||
107 | foreach ($child->attributes() as $key => $value) { |
||
108 | if ("name" === $key) { |
||
109 | $name = (string) $value; |
||
110 | } |
||
111 | $date->{$key} = (string) $value; |
||
112 | } |
||
113 | if ($child->getName() !== "name-part" && !$this->terms->containsKey($name)) { |
||
114 | $this->terms->put($name, []); |
||
115 | } |
||
116 | $this->date->put($form, $date); |
||
117 | } |
||
118 | |||
119 | break; |
||
120 | } |
||
159 |
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.