| Conditions | 5 | 
| Paths | 8 | 
| Total Lines | 69 | 
| Code Lines | 47 | 
| 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 | ||
| 102 | public static function fromXML(DOMElement $xml): static | ||
| 103 |     { | ||
| 104 | Assert::same($xml->localName, 'RoleDescriptor', InvalidDOMElementException::class); | ||
| 105 | Assert::same($xml->namespaceURI, C::NS_MD, InvalidDOMElementException::class); | ||
| 106 | Assert::true( | ||
| 107 | $xml->hasAttributeNS(C::NS_XSI, 'type'), | ||
| 108 | 'Missing required xsi:type in <saml:RoleDescriptor> element.', | ||
| 109 | SchemaViolationException::class | ||
| 110 | ); | ||
| 111 | |||
| 112 | $type = $xml->getAttributeNS(C::NS_XSI, 'type'); | ||
| 113 | Assert::validQName($type, SchemaViolationException::class); | ||
| 114 | |||
| 115 | // first, try to resolve the type to a full namespaced version | ||
| 116 |         $qname = explode(':', $type, 2); | ||
| 117 |         if (count($qname) === 2) { | ||
| 118 | list($prefix, $element) = $qname; | ||
| 119 |         } else { | ||
| 120 | $prefix = null; | ||
| 121 | list($element) = $qname; | ||
| 122 | } | ||
| 123 | $ns = $xml->lookupNamespaceUri($prefix); | ||
| 124 |         $type = ($ns === null) ? $element : implode(':', [$ns, $element]); | ||
| 125 | |||
| 126 | // now check if we have a handler registered for it | ||
| 127 | $handler = Utils::getContainer()->getExtensionHandler($type); | ||
| 128 |         if ($handler === null) { | ||
| 129 | // we don't have a handler, proceed with unknown RoleDescriptor | ||
| 130 | $protocols = self::getAttribute($xml, 'protocolSupportEnumeration'); | ||
| 131 | |||
| 132 | $validUntil = self::getOptionalAttribute($xml, 'validUntil', null); | ||
| 133 | $orgs = Organization::getChildrenOfClass($xml); | ||
| 134 | Assert::maxCount( | ||
| 135 | $orgs, | ||
| 136 | 1, | ||
| 137 | 'More than one Organization found in this descriptor', | ||
| 138 | TooManyElementsException::class, | ||
| 139 | ); | ||
| 140 | |||
| 141 | $extensions = Extensions::getChildrenOfClass($xml); | ||
| 142 | Assert::maxCount( | ||
| 143 | $extensions, | ||
| 144 | 1, | ||
| 145 | 'Only one md:Extensions element is allowed.', | ||
| 146 | TooManyElementsException::class, | ||
| 147 | ); | ||
| 148 | |||
| 149 | return new UnknownRoleDescriptor( | ||
| 150 | new Chunk($xml), | ||
| 151 | $type, | ||
| 152 |                 preg_split('/[\s]+/', trim($protocols)), | ||
| 153 | self::getOptionalAttribute($xml, 'ID', null), | ||
| 154 | $validUntil !== null ? XMLUtils::xsDateTimeToTimestamp($validUntil) : null, | ||
| 155 | self::getOptionalAttribute($xml, 'cacheDuration', null), | ||
| 156 | array_pop($extensions), | ||
| 157 | self::getOptionalAttribute($xml, 'errorURL', null), | ||
| 158 | KeyDescriptor::getChildrenOfClass($xml), | ||
| 159 | array_pop($orgs), | ||
| 160 | ContactPerson::getChildrenOfClass($xml), | ||
| 161 | ); | ||
| 162 | } | ||
| 163 | |||
| 164 | Assert::subclassOf( | ||
| 165 | $handler, | ||
| 166 | AbstractRoleDescriptor::class, | ||
| 167 | 'Elements implementing RoleDescriptor must extend \SimpleSAML\SAML2\XML\saml\AbstractRoleDescriptor.', | ||
| 168 | ); | ||
| 169 | |||
| 170 | return $handler::fromXML($xml); | ||
| 171 | } | ||
| 190 | 
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