| Conditions | 21 |
| Paths | 16 |
| Total Lines | 66 |
| Code Lines | 41 |
| 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 |
||
| 47 | protected static function getChildElementsFromXML( |
||
| 48 | DOMElement $xml, |
||
| 49 | string|array|null $namespace = null, |
||
| 50 | ): array { |
||
| 51 | $namespace = $namespace ?? static::XS_ANY_ELT_NAMESPACE; |
||
| 52 | $exclusionList = self::getElementExclusions(); |
||
| 53 | $registry = ElementRegistry::getInstance(); |
||
| 54 | $elements = []; |
||
| 55 | |||
| 56 | // Validate namespace value |
||
| 57 | if (!is_array($namespace)) { |
||
| 58 | // Must be one of the predefined values |
||
| 59 | Assert::oneOf($namespace, NS::$PREDEFINED); |
||
| 60 | |||
| 61 | foreach ($xml->childNodes as $elt) { |
||
| 62 | if (!($elt instanceof DOMElement)) { |
||
| 63 | continue; |
||
| 64 | } elseif ( |
||
| 65 | $exclusionList |
||
| 66 | && (in_array([$elt->namespaceURI, $elt->localName], $exclusionList, true) |
||
| 67 | || in_array([$elt->namespaceURI, '*'], $exclusionList, true)) |
||
| 68 | ) { |
||
| 69 | continue; |
||
| 70 | } elseif ($namespace === NS::OTHER && in_array($elt->namespaceURI, [self::NS, null], true)) { |
||
| 71 | continue; |
||
| 72 | } elseif ($namespace === NS::TARGETNAMESPACE && $elt->namespaceURI !== self::NS) { |
||
| 73 | continue; |
||
| 74 | } elseif ($namespace === NS::LOCAL && $elt->namespaceURI !== null) { |
||
| 75 | continue; |
||
| 76 | } |
||
| 77 | |||
| 78 | $handler = $registry->getElementHandler($elt->namespaceURI, $elt->localName); |
||
| 79 | $elements[] = ($handler === null) ? Chunk::fromXML($elt) : $handler::fromXML($elt); |
||
| 80 | } |
||
| 81 | } else { |
||
| 82 | // Array must be non-empty and cannot contain ##any or ##other |
||
| 83 | Assert::notEmpty($namespace); |
||
| 84 | Assert::allStringNotEmpty($namespace); |
||
| 85 | Assert::allNotSame($namespace, NS::ANY); |
||
| 86 | Assert::allNotSame($namespace, NS::OTHER); |
||
| 87 | |||
| 88 | // Replace the ##targetedNamespace with the actual namespace |
||
| 89 | if (($key = array_search(NS::TARGETNAMESPACE, $namespace)) !== false) { |
||
| 90 | $namespace[$key] = self::NS; |
||
| 91 | } |
||
| 92 | |||
| 93 | // Replace the ##local with null |
||
| 94 | if (($key = array_search(NS::LOCAL, $namespace)) !== false) { |
||
| 95 | $namespace[$key] = null; |
||
| 96 | } |
||
| 97 | |||
| 98 | foreach ($xml->childNodes as $elt) { |
||
| 99 | if (!($elt instanceof DOMElement)) { |
||
| 100 | continue; |
||
| 101 | } elseif (in_array([$elt->namespaceURI, $elt->localName], $exclusionList, true)) { |
||
| 102 | continue; |
||
| 103 | } elseif (!in_array($elt->namespaceURI, $namespace, true)) { |
||
| 104 | continue; |
||
| 105 | } |
||
| 106 | |||
| 107 | $handler = $registry->getElementHandler($elt->namespaceURI, $elt->localName); |
||
| 108 | $elements[] = ($handler === null) ? Chunk::fromXML($elt) : $handler::fromXML($elt); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | |||
| 112 | return $elements; |
||
| 113 | } |
||
| 242 |
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