| Conditions | 6 | 
| Paths | 6 | 
| Total Lines | 54 | 
| Code Lines | 35 | 
| 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  | 
            ||
| 99 | public static function fromXML(DOMElement $xml): object  | 
            ||
| 100 |     { | 
            ||
| 101 | Assert::same($xml->localName, 'ArtifactResponse');  | 
            ||
| 102 | Assert::same($xml->namespaceURI, ArtifactResponse::NS);  | 
            ||
| 103 | |||
| 104 | $id = self::getAttribute($xml, 'ID');  | 
            ||
| 105 | $version = self::getAttribute($xml, 'Version');  | 
            ||
| 106 | $issueInstant = Utils::xsDateTimeToTimestamp(self::getAttribute($xml, 'IssueInstant'));  | 
            ||
| 107 | $inResponseTo = self::getAttribute($xml, 'InResponseTo', null);  | 
            ||
| 108 | $destination = self::getAttribute($xml, 'Destination', null);  | 
            ||
| 109 | $consent = self::getAttribute($xml, 'Consent', null);  | 
            ||
| 110 | |||
| 111 | $issuer = Issuer::getChildrenOfClass($xml);  | 
            ||
| 112 | Assert::countBetween($issuer, 0, 1);  | 
            ||
| 113 | |||
| 114 | // Find children; they should come last, after the Status-element  | 
            ||
| 115 | $status = Utils::xpQuery($xml, './saml_protocol:Status');  | 
            ||
| 116 | $status = $status[0];  | 
            ||
| 117 | |||
| 118 | /** @psalm-suppress RedundantCondition */  | 
            ||
| 119 |         for ($any = $status->nextSibling; $any instanceof DOMNode; $any = $any->nextSibling) { | 
            ||
| 120 |             if ($any instanceof DOMElement) { | 
            ||
| 121 | break;  | 
            ||
| 122 | }  | 
            ||
| 123 | /* Ignore comments and text nodes. */  | 
            ||
| 124 | }  | 
            ||
| 125 | |||
| 126 | $status = Status::getChildrenOfClass($xml);  | 
            ||
| 127 | Assert::count($status, 1);  | 
            ||
| 128 | |||
| 129 | $extensions = Extensions::getChildrenOfClass($xml);  | 
            ||
| 130 | Assert::maxCount($extensions, 1, 'Only one saml:Extensions element is allowed.');  | 
            ||
| 131 | |||
| 132 | $signature = Signature::getChildrenOfClass($xml);  | 
            ||
| 133 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.');  | 
            ||
| 134 | |||
| 135 | $response = new self(  | 
            ||
| 136 | array_pop($status),  | 
            ||
| 137 | empty($issuer) ? null : array_pop($issuer),  | 
            ||
| 138 | $id,  | 
            ||
| 139 | $version,  | 
            ||
| 140 | $issueInstant,  | 
            ||
| 141 | $inResponseTo,  | 
            ||
| 142 | $destination,  | 
            ||
| 143 | $consent,  | 
            ||
| 144 | empty($extensions) ? null : array_pop($extensions),  | 
            ||
| 145 | $any  | 
            ||
| 146 | );  | 
            ||
| 147 | |||
| 148 |         if (!empty($signature)) { | 
            ||
| 149 | $response->setSignature($signature[0]);  | 
            ||
| 150 | }  | 
            ||
| 151 | |||
| 152 | return $response;  | 
            ||
| 153 | }  | 
            ||
| 173 |