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