| Conditions | 11 |
| Paths | 7 |
| Total Lines | 51 |
| Code Lines | 33 |
| 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 |
||
| 93 | public static function fromXML(DOMElement $xml): static |
||
| 94 | { |
||
| 95 | Assert::same($xml->localName, 'AttributeValue', InvalidDOMElementException::class); |
||
| 96 | Assert::same($xml->namespaceURI, AttributeValue::NS, InvalidDOMElementException::class); |
||
| 97 | |||
| 98 | if ($xml->childElementCount > 0) { |
||
| 99 | $node = $xml->firstElementChild; |
||
| 100 | |||
| 101 | if (str_contains($node->tagName, ':')) { |
||
| 102 | list($prefix, $eltName) = explode(':', $node->tagName); |
||
| 103 | $className = sprintf('\SimpleSAML\SAML2\XML\%s\%s', $prefix, $eltName); |
||
| 104 | |||
| 105 | if (class_exists($className)) { |
||
| 106 | $value = $className::fromXML($node); |
||
| 107 | } else { |
||
| 108 | $value = Chunk::fromXML($node); |
||
| 109 | } |
||
| 110 | } else { |
||
| 111 | $value = Chunk::fromXML($node); |
||
| 112 | } |
||
| 113 | } elseif ( |
||
| 114 | $xml->hasAttributeNS(C_XSI::NS_XSI, "type") && |
||
| 115 | $xml->getAttributeNS(C_XSI::NS_XSI, "type") === "xs:integer" |
||
| 116 | ) { |
||
| 117 | Assert::numeric($xml->textContent); |
||
| 118 | |||
| 119 | // we have an integer as value |
||
| 120 | $value = intval($xml->textContent); |
||
| 121 | } elseif ( |
||
| 122 | $xml->hasAttributeNS(C_XSI::NS_XSI, "type") && |
||
| 123 | $xml->getAttributeNS(C_XSI::NS_XSI, "type") === "xs:dateTime" |
||
| 124 | ) { |
||
| 125 | Assert::validDateTime($xml->textContent); |
||
| 126 | |||
| 127 | // we have a dateTime as value |
||
| 128 | $value = new DateTimeImmutable($xml->textContent); |
||
| 129 | } elseif ( |
||
| 130 | // null value |
||
| 131 | $xml->hasAttributeNS(C_XSI::NS_XSI, "nil") && |
||
| 132 | ($xml->getAttributeNS(C_XSI::NS_XSI, "nil") === "1" || |
||
| 133 | $xml->getAttributeNS(C_XSI::NS_XSI, "nil") === "true") |
||
| 134 | ) { |
||
| 135 | Assert::isEmpty($xml->nodeValue); |
||
| 136 | Assert::isEmpty($xml->textContent); |
||
| 137 | |||
| 138 | $value = null; |
||
| 139 | } else { |
||
| 140 | $value = $xml->textContent; |
||
| 141 | } |
||
| 142 | |||
| 143 | return new static($value); |
||
| 144 | } |
||
| 187 |
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