Conditions | 15 |
Paths | 38 |
Total Lines | 51 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
122 | protected function addDataItem(DOMDocument $dom, $node, $key, $value, $format): void |
||
123 | { |
||
124 | if (is_object($value) && method_exists($value, 'toArray') && is_callable([$value, 'toArray'])) { |
||
125 | $value = $value->toArray(); |
||
126 | } |
||
127 | |||
128 | if (!is_array($value)) { |
||
129 | if (is_bool($value)) { |
||
130 | $value = (int)$value; |
||
131 | } elseif ($value === null) { |
||
132 | $value = ''; |
||
133 | } |
||
134 | $isNamespace = strpos($key, 'xmlns:'); |
||
135 | if ($isNamespace !== false) { |
||
136 | /** @psalm-suppress PossiblyUndefinedMethod */ |
||
137 | $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, (string)$value); |
||
138 | return; |
||
139 | } |
||
140 | if ($key[0] !== '@' && $format === 'tags') { |
||
141 | if (!is_numeric($value)) { |
||
142 | // Escape special characters |
||
143 | // https://www.w3.org/TR/REC-xml/#syntax |
||
144 | // https://bugs.php.net/bug.php?id=36795 |
||
145 | $child = $dom->createElement($key, ''); |
||
146 | $child->appendChild(new DOMText((string)$value)); |
||
147 | } else { |
||
148 | $child = $dom->createElement($key, (string)$value); |
||
149 | } |
||
150 | $node->appendChild($child); |
||
151 | } else { |
||
152 | if ($key[0] === '@') { |
||
153 | $key = substr($key, 1); |
||
154 | } |
||
155 | $attribute = $dom->createAttribute($key); |
||
156 | $attribute->appendChild($dom->createTextNode((string)$value)); |
||
157 | $node->appendChild($attribute); |
||
158 | } |
||
159 | } else { |
||
160 | if ($key[0] === '@') { |
||
161 | throw new XmlException('Invalid array'); |
||
162 | } |
||
163 | if (is_numeric(implode('', array_keys($value)))) { |
||
164 | // List |
||
165 | foreach ($value as $item) { |
||
166 | $itemData = compact('dom', 'node', 'key', 'format'); |
||
167 | $itemData['value'] = $item; |
||
168 | $this->createChild($itemData); |
||
169 | } |
||
170 | } else { |
||
171 | // Struct |
||
172 | $this->createChild(compact('dom', 'node', 'key', 'value', 'format')); |
||
173 | } |
||
228 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths