| Conditions | 6 |
| Paths | 6 |
| Total Lines | 63 |
| Code Lines | 40 |
| 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 |
||
| 94 | public static function fromXML(DOMElement $xml): static |
||
| 95 | { |
||
| 96 | Assert::same($xml->localName, 'ArtifactResponse', InvalidDOMElementException::class); |
||
| 97 | Assert::same($xml->namespaceURI, ArtifactResponse::NS, InvalidDOMElementException::class); |
||
| 98 | |||
| 99 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||
| 100 | Assert::true(version_compare('2.0', $version->getValue(), '<='), RequestVersionTooLowException::class); |
||
| 101 | Assert::true(version_compare('2.0', $version->getValue(), '>='), RequestVersionTooHighException::class); |
||
| 102 | |||
| 103 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 104 | Assert::countBetween($issuer, 0, 1); |
||
| 105 | |||
| 106 | // find message; it should come last, after the Status-element |
||
| 107 | $status = XPath::xpQuery($xml, './saml_protocol:Status', XPath::getXPath($xml)); |
||
| 108 | $status = $status[0]; |
||
| 109 | $message = null; |
||
| 110 | |||
| 111 | /** @psalm-suppress RedundantCondition */ |
||
| 112 | for ($child = $status->nextSibling; $child !== null; $child = $child->nextSibling) { |
||
| 113 | if ($child instanceof DOMElement) { |
||
| 114 | $message = MessageFactory::fromXML($child); |
||
| 115 | break; |
||
| 116 | } |
||
| 117 | /* Ignore comments and text nodes. */ |
||
| 118 | } |
||
| 119 | |||
| 120 | $status = Status::getChildrenOfClass($xml); |
||
| 121 | Assert::count($status, 1); |
||
| 122 | |||
| 123 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 124 | Assert::maxCount( |
||
| 125 | $extensions, |
||
| 126 | 1, |
||
| 127 | 'Only one saml:Extensions element is allowed.', |
||
| 128 | TooManyElementsException::class, |
||
| 129 | ); |
||
| 130 | |||
| 131 | $signature = Signature::getChildrenOfClass($xml); |
||
| 132 | Assert::maxCount( |
||
| 133 | $signature, |
||
| 134 | 1, |
||
| 135 | 'Only one ds:Signature element is allowed.', |
||
| 136 | TooManyElementsException::class, |
||
| 137 | ); |
||
| 138 | |||
| 139 | $response = new static( |
||
| 140 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 141 | array_pop($status), |
||
| 142 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 143 | empty($issuer) ? null : array_pop($issuer), |
||
| 144 | self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null), |
||
| 145 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 146 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 147 | empty($extensions) ? null : array_pop($extensions), |
||
| 148 | $message, |
||
| 149 | ); |
||
| 150 | |||
| 151 | if (!empty($signature)) { |
||
| 152 | $response->setSignature($signature[0]); |
||
| 153 | $response->setXML($xml); |
||
| 154 | } |
||
| 155 | |||
| 156 | return $response; |
||
| 157 | } |
||
| 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