| Conditions | 2 |
| Paths | 2 |
| Total Lines | 51 |
| Code Lines | 36 |
| 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 |
||
| 114 | public static function fromXML(DOMElement $xml): object |
||
| 115 | { |
||
| 116 | Assert::same($xml->localName, 'AuthnQueryQuery', InvalidDOMElementException::class); |
||
| 117 | Assert::same($xml->namespaceURI, AuthnQuery::NS, InvalidDOMElementException::class); |
||
| 118 | |||
| 119 | Assert::true(version_compare('2.0', self::getAttribute($xml, 'Version'), '<='), RequestVersionTooLowException::class); |
||
| 120 | Assert::true(version_compare('2.0', self::getAttribute($xml, 'Version'), '>='), RequestVersionTooHighException::class); |
||
| 121 | |||
| 122 | $id = self::getAttribute($xml, 'ID'); |
||
| 123 | $sessionIndex = self::getAttribute($xml, 'SessionIndex', null); |
||
| 124 | $destination = self::getAttribute($xml, 'Destination', null); |
||
| 125 | $consent = self::getAttribute($xml, 'Consent', null); |
||
| 126 | |||
| 127 | $issueInstant = self::getAttribute($xml, 'IssueInstant'); |
||
| 128 | Assert::validDateTimeZulu($issueInstant, ProtocolViolationException::class); |
||
| 129 | $issueInstant = XMLUtils::xsDateTimeToTimestamp($issueInstant); |
||
| 130 | |||
| 131 | $requestedAuthnContext = RequestedAuthnContext::getChildrenOfClass($xml); |
||
| 132 | Assert::countBetween($issuer, 0, 1); |
||
| 133 | |||
| 134 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 135 | Assert::countBetween($issuer, 0, 1); |
||
| 136 | |||
| 137 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 138 | Assert::maxCount($extensions, 1, 'Only one saml:Extensions element is allowed.', TooManyElementsException::class); |
||
| 139 | |||
| 140 | $subject = Subject::getChildrenOfClass($xml); |
||
| 141 | Assert::notEmpty($subject, 'Missing subject in subject query.', MissingElementException::class); |
||
| 142 | Assert::maxCount($subject, 1, 'More than one <saml:Subject> in AttributeQuery', TooManyElementsException::class); |
||
| 143 | |||
| 144 | $signature = Signature::getChildrenOfClass($xml); |
||
| 145 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.', TooManyElementsException::class); |
||
| 146 | |||
| 147 | $request = new self( |
||
| 148 | array_pop($subject), |
||
| 149 | array_pop($requestedAuthnContext), |
||
| 150 | $sessionIndex, |
||
| 151 | array_pop($issuer), |
||
| 152 | $id, |
||
| 153 | $issueInstant, |
||
| 154 | $destination, |
||
| 155 | $consent, |
||
| 156 | array_pop($extensions) |
||
| 157 | ); |
||
| 158 | |||
| 159 | if (!empty($signature)) { |
||
| 160 | $request->setSignature($signature[0]); |
||
| 161 | $request->setXML($xml); |
||
| 162 | } |
||
| 163 | |||
| 164 | return $request; |
||
| 165 | } |
||
| 189 |
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