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