Conditions | 2 |
Paths | 2 |
Total Lines | 55 |
Code Lines | 37 |
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 |
||
105 | public static function fromXML(DOMElement $xml): static |
||
106 | { |
||
107 | Assert::same($xml->localName, 'RoleDescriptor', InvalidDOMElementException::class); |
||
108 | Assert::same($xml->namespaceURI, C::NS_MD, InvalidDOMElementException::class); |
||
109 | Assert::true( |
||
110 | $xml->hasAttributeNS(C::NS_XSI, 'type'), |
||
111 | 'Missing required xsi:type in <md:RoleDescriptor> element.', |
||
112 | SchemaViolationException::class, |
||
113 | ); |
||
114 | |||
115 | $type = QNameValue::fromDocument($xml->getAttributeNS(C::NS_XSI, 'type'), $xml); |
||
116 | |||
117 | // now check if we have a handler registered for it |
||
118 | $handler = Utils::getContainer()->getExtensionHandler($type); |
||
119 | if ($handler === null) { |
||
120 | // we don't have a handler, proceed with unknown RoleDescriptor |
||
121 | $orgs = Organization::getChildrenOfClass($xml); |
||
122 | Assert::maxCount( |
||
123 | $orgs, |
||
124 | 1, |
||
125 | 'More than one Organization found in this descriptor', |
||
126 | TooManyElementsException::class, |
||
127 | ); |
||
128 | |||
129 | $extensions = Extensions::getChildrenOfClass($xml); |
||
130 | Assert::maxCount( |
||
131 | $extensions, |
||
132 | 1, |
||
133 | 'Only one md:Extensions element is allowed.', |
||
134 | TooManyElementsException::class, |
||
135 | ); |
||
136 | |||
137 | return new UnknownRoleDescriptor( |
||
138 | new Chunk($xml), |
||
139 | $type, |
||
140 | self::getAttribute($xml, 'protocolSupportEnumeration', AnyURIListValue::class), |
||
141 | self::getOptionalAttribute($xml, 'ID', IDValue::class, null), |
||
142 | self::getOptionalAttribute($xml, 'validUntil', SAMLDateTimeValue::class, null), |
||
143 | self::getOptionalAttribute($xml, 'cacheDuration', DurationValue::class, null), |
||
144 | array_pop($extensions), |
||
145 | self::getOptionalAttribute($xml, 'errorURL', SAMLAnyURIValue::class, null), |
||
146 | KeyDescriptor::getChildrenOfClass($xml), |
||
147 | array_pop($orgs), |
||
148 | ContactPerson::getChildrenOfClass($xml), |
||
149 | self::getAttributesNSFromXML($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 | } |
||
162 |
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