| Conditions | 2 |
| Paths | 2 |
| Total Lines | 61 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 84 | public static function fromXML(DOMElement $xml): static |
||
| 85 | { |
||
| 86 | Assert::same($xml->localName, 'AssertionIDRequest', InvalidDOMElementException::class); |
||
| 87 | Assert::same($xml->namespaceURI, AssertionIDRequest::NS, InvalidDOMElementException::class); |
||
| 88 | |||
| 89 | $assertionIDRef = AssertionIDRef::getChildrenOfClass($xml); |
||
| 90 | Assert::minCount( |
||
| 91 | $assertionIDRef, |
||
| 92 | 1, |
||
| 93 | 'At least one <samlp:AssertionIDRef> element is required.', |
||
| 94 | TooManyElementsException::class, |
||
| 95 | ); |
||
| 96 | |||
| 97 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 98 | Assert::maxCount($issuer, 1, 'Only one <saml:Issuer> element is allowed.', TooManyElementsException::class); |
||
| 99 | |||
| 100 | $version = self::getAttribute($xml, 'Version'); |
||
| 101 | Assert::true(version_compare('2.0', $version, '<='), RequestVersionTooLowException::class); |
||
| 102 | Assert::true(version_compare('2.0', $version, '>='), RequestVersionTooHighException::class); |
||
| 103 | |||
| 104 | $issueInstant = self::getAttribute($xml, 'IssueInstant'); |
||
| 105 | // Strip sub-seconds - See paragraph 1.3.3 of SAML core specifications |
||
| 106 | $issueInstant = preg_replace('/([.][0-9]+Z)$/', 'Z', $issueInstant, 1); |
||
| 107 | |||
| 108 | Assert::validDateTimeZulu($issueInstant, ProtocolViolationException::class); |
||
|
|
|||
| 109 | $issueInstant = XMLUtils::xsDateTimeToTimestamp($issueInstant); |
||
| 110 | |||
| 111 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 112 | Assert::maxCount( |
||
| 113 | $extensions, |
||
| 114 | 1, |
||
| 115 | 'Only one <samlp:Extensions> element is allowed.', |
||
| 116 | TooManyElementsException::class, |
||
| 117 | ); |
||
| 118 | |||
| 119 | $signature = Signature::getChildrenOfClass($xml); |
||
| 120 | Assert::maxCount( |
||
| 121 | $signature, |
||
| 122 | 1, |
||
| 123 | 'Only one <ds:Signature> element is allowed.', |
||
| 124 | TooManyElementsException::class, |
||
| 125 | ); |
||
| 126 | |||
| 127 | $request = new static( |
||
| 128 | $assertionIDRef, |
||
| 129 | array_pop($issuer), |
||
| 130 | self::getAttribute($xml, 'ID'), |
||
| 131 | $version, |
||
| 132 | $issueInstant, |
||
| 133 | self::getAttribute($xml, 'Destination', null), |
||
| 134 | self::getAttribute($xml, 'Consent', null), |
||
| 135 | array_pop($extensions), |
||
| 136 | ); |
||
| 137 | |||
| 138 | if (!empty($signature)) { |
||
| 139 | $request->setSignature($signature[0]); |
||
| 140 | $request->messageContainedSignatureUponConstruction = true; |
||
| 141 | $request->setXML($xml); |
||
| 142 | } |
||
| 143 | |||
| 144 | return $request; |
||
| 145 | } |
||
| 165 |
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