| Conditions | 2 |
| Paths | 2 |
| Total Lines | 52 |
| Code Lines | 35 |
| 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 |
||
| 100 | public static function fromXML(DOMElement $xml): static |
||
| 101 | { |
||
| 102 | Assert::same($xml->localName, 'AuthnQuery', InvalidDOMElementException::class); |
||
| 103 | Assert::same($xml->namespaceURI, AuthnQuery::NS, InvalidDOMElementException::class); |
||
| 104 | |||
| 105 | $version = self::getAttribute($xml, 'Version'); |
||
| 106 | Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class); |
||
| 107 | Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class); |
||
| 108 | |||
| 109 | $requestedAuthnContext = RequestedAuthnContext::getChildrenOfClass($xml); |
||
| 110 | |||
| 111 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 112 | Assert::countBetween($issuer, 0, 1); |
||
| 113 | |||
| 114 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 115 | Assert::maxCount( |
||
| 116 | $extensions, |
||
| 117 | 1, |
||
| 118 | 'Only one saml:Extensions element is allowed.', |
||
| 119 | TooManyElementsException::class, |
||
| 120 | ); |
||
| 121 | |||
| 122 | $subject = Subject::getChildrenOfClass($xml); |
||
| 123 | Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class); |
||
| 124 | Assert::maxCount( |
||
| 125 | $subject, |
||
| 126 | 1, |
||
| 127 | 'More than one <saml:Subject> in AttributeQuery', |
||
| 128 | TooManyElementsException::class, |
||
| 129 | ); |
||
| 130 | |||
| 131 | $signature = Signature::getChildrenOfClass($xml); |
||
| 132 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||
| 133 | |||
| 134 | $request = new static( |
||
| 135 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 136 | array_pop($subject), |
||
| 137 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 138 | array_pop($requestedAuthnContext), |
||
| 139 | self::getOptionalAttribute($xml, 'SessionIndex', SAMLStringValue::class, null), |
||
| 140 | array_pop($issuer), |
||
| 141 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 142 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 143 | array_pop($extensions), |
||
| 144 | ); |
||
| 145 | |||
| 146 | if (!empty($signature)) { |
||
| 147 | $request->setSignature($signature[0]); |
||
| 148 | $request->setXML($xml); |
||
| 149 | } |
||
| 150 | |||
| 151 | return $request; |
||
| 152 | } |
||
| 173 |
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