| Conditions | 2 |
| Paths | 2 |
| Total Lines | 67 |
| Code Lines | 45 |
| 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 |
||
| 115 | public static function fromXML(DOMElement $xml): static |
||
| 116 | { |
||
| 117 | Assert::same($xml->localName, 'AuthzDecisionQuery', InvalidDOMElementException::class); |
||
| 118 | Assert::same($xml->namespaceURI, AuthzDecisionQuery::NS, InvalidDOMElementException::class); |
||
| 119 | |||
| 120 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||
| 121 | Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class); |
||
| 122 | Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class); |
||
| 123 | |||
| 124 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 125 | Assert::countBetween($issuer, 0, 1); |
||
| 126 | |||
| 127 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 128 | Assert::maxCount( |
||
| 129 | $extensions, |
||
| 130 | 1, |
||
| 131 | 'Only one saml:Extensions element is allowed.', |
||
| 132 | TooManyElementsException::class, |
||
| 133 | ); |
||
| 134 | |||
| 135 | $subject = Subject::getChildrenOfClass($xml); |
||
| 136 | Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class); |
||
| 137 | Assert::maxCount( |
||
| 138 | $subject, |
||
| 139 | 1, |
||
| 140 | 'More than one <saml:Subject> in AuthzDecisionQuery', |
||
| 141 | TooManyElementsException::class, |
||
| 142 | ); |
||
| 143 | |||
| 144 | $action = Action::getChildrenOfClass($xml); |
||
| 145 | Assert::minCount( |
||
| 146 | $action, |
||
| 147 | 1, |
||
| 148 | 'Missing <saml:Action> in <saml:AuthzDecisionQuery>', |
||
| 149 | MissingElementException::class, |
||
| 150 | ); |
||
| 151 | |||
| 152 | $evidence = Evidence::getChildrenOfClass($xml); |
||
| 153 | Assert::maxCount( |
||
| 154 | $evidence, |
||
| 155 | 1, |
||
| 156 | 'Too many <saml:Evidence> in <saml:AuthzDecisionQuery>', |
||
| 157 | TooManyElementsException::class, |
||
| 158 | ); |
||
| 159 | |||
| 160 | $signature = Signature::getChildrenOfClass($xml); |
||
| 161 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||
| 162 | |||
| 163 | $request = new static( |
||
| 164 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 165 | array_pop($subject), |
||
| 166 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 167 | self::getAttribute($xml, 'Resource', SAMLAnyURIValue::class), |
||
| 168 | $action, |
||
| 169 | array_pop($evidence), |
||
| 170 | array_pop($issuer), |
||
| 171 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 172 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 173 | array_pop($extensions), |
||
| 174 | ); |
||
| 175 | |||
| 176 | if (!empty($signature)) { |
||
| 177 | $request->setSignature($signature[0]); |
||
| 178 | $request->setXML($xml); |
||
| 179 | } |
||
| 180 | |||
| 181 | return $request; |
||
| 182 | } |
||
| 205 |
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