| Conditions | 2 |
| Paths | 2 |
| Total Lines | 59 |
| 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 |
||
| 47 | public static function fromXML(DOMElement $xml): static |
||
| 48 | { |
||
| 49 | Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
||
| 50 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
| 51 | |||
| 52 | $version = self::getAttribute($xml, 'Version', SAMLStringValue::class); |
||
| 53 | Assert::true(version_compare('2.0', strval($version), '<='), RequestVersionTooLowException::class); |
||
| 54 | Assert::true(version_compare('2.0', strval($version), '>='), RequestVersionTooHighException::class); |
||
| 55 | |||
| 56 | $issuer = Issuer::getChildrenOfClass($xml); |
||
| 57 | Assert::maxCount($issuer, 1, 'Only one <saml:Issuer> element is allowed.', TooManyElementsException::class); |
||
| 58 | |||
| 59 | $extensions = Extensions::getChildrenOfClass($xml); |
||
| 60 | Assert::maxCount( |
||
| 61 | $extensions, |
||
| 62 | 1, |
||
| 63 | 'Only one <samlp:Extensions> element is allowed.', |
||
| 64 | TooManyElementsException::class, |
||
| 65 | ); |
||
| 66 | |||
| 67 | $signature = Signature::getChildrenOfClass($xml); |
||
| 68 | Assert::maxCount( |
||
| 69 | $signature, |
||
| 70 | 1, |
||
| 71 | 'Only one <ds:Signature> element is allowed.', |
||
| 72 | TooManyElementsException::class, |
||
| 73 | ); |
||
| 74 | |||
| 75 | $newId = NewID::getChildrenOfClass($xml); |
||
| 76 | Assert::maxCount($newId, 1, TooManyElementsException::class); |
||
| 77 | |||
| 78 | $newEncryptedId = NewEncryptedID::getChildrenOfClass($xml); |
||
| 79 | Assert::maxCount($newEncryptedId, 1, TooManyElementsException::class); |
||
| 80 | |||
| 81 | $terminate = Terminate::getChildrenOfClass($xml); |
||
| 82 | Assert::maxCount($terminate, 1, TooManyElementsException::class); |
||
| 83 | |||
| 84 | $newIdentifier = array_merge($newId, $newEncryptedId, $terminate); |
||
| 85 | Assert::minCount($newIdentifier, 1, MissingElementException::class); |
||
| 86 | Assert::maxCount($newIdentifier, 1, TooManyElementsException::class); |
||
| 87 | |||
| 88 | $request = new static( |
||
| 89 | self::getIdentifierFromXML($xml), |
||
| 90 | array_pop($newIdentifier), |
||
| 91 | self::getAttribute($xml, 'ID', IDValue::class), |
||
| 92 | array_pop($issuer), |
||
| 93 | self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), |
||
| 94 | self::getOptionalAttribute($xml, 'Destination', SAMLAnyURIValue::class, null), |
||
| 95 | self::getOptionalAttribute($xml, 'Consent', SAMLAnyURIValue::class, null), |
||
| 96 | array_pop($extensions), |
||
| 97 | ); |
||
| 98 | |||
| 99 | if (!empty($signature)) { |
||
| 100 | $request->setSignature($signature[0]); |
||
| 101 | $request->messageContainedSignatureUponConstruction = true; |
||
| 102 | $request->setXML($xml); |
||
| 103 | } |
||
| 104 | |||
| 105 | return $request; |
||
| 106 | } |
||
| 108 |
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