Conditions | 9 |
Paths | 12 |
Total Lines | 58 |
Code Lines | 41 |
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 |
||
102 | public static function fromXML(DOMElement $xml): object |
||
103 | { |
||
104 | Assert::same($xml->localName, 'Response'); |
||
105 | Assert::same($xml->namespaceURI, Response::NS); |
||
106 | |||
107 | $id = self::getAttribute($xml, 'ID'); |
||
108 | $version = self::getAttribute($xml, 'Version'); |
||
109 | $issueInstant = Utils::xsDateTimeToTimestamp(self::getAttribute($xml, 'IssueInstant')); |
||
110 | $inResponseTo = self::getAttribute($xml, 'InResponseTo', null); |
||
111 | $destination = self::getAttribute($xml, 'Destination', null); |
||
112 | $consent = self::getAttribute($xml, 'Consent', null); |
||
113 | |||
114 | $issuer = Issuer::getChildrenOfClass($xml); |
||
115 | Assert::countBetween($issuer, 0, 1); |
||
116 | |||
117 | $status = Status::getChildrenOfClass($xml); |
||
118 | Assert::count($status, 1); |
||
119 | |||
120 | $extensions = Extensions::getChildrenOfClass($xml); |
||
121 | Assert::maxCount($extensions, 1, 'Only one saml:Extensions element is allowed.'); |
||
122 | |||
123 | $assertions = []; |
||
124 | foreach ($xml->childNodes as $node) { |
||
125 | if ($node->namespaceURI !== Constants::NS_SAML) { |
||
126 | continue; |
||
127 | } elseif (!($node instanceof DOMElement)) { |
||
128 | continue; |
||
129 | } |
||
130 | |||
131 | if ($node->localName === 'Assertion') { |
||
132 | $assertions[] = new Assertion($node); |
||
133 | } elseif ($node->localName === 'EncryptedAssertion') { |
||
134 | $assertions[] = EncryptedAssertion::fromXML($node); |
||
135 | } |
||
136 | } |
||
137 | |||
138 | $signature = Signature::getChildrenOfClass($xml); |
||
139 | Assert::maxCount($signature, 1, 'Only one ds:Signature element is allowed.'); |
||
140 | |||
141 | $response = new self( |
||
142 | array_pop($status), |
||
143 | empty($issuer) ? null : array_pop($issuer), |
||
144 | $id, |
||
145 | $version, |
||
146 | $issueInstant, |
||
147 | $inResponseTo, |
||
148 | $destination, |
||
149 | $consent, |
||
150 | empty($extensions) ? null : array_pop($extensions), |
||
151 | $assertions |
||
152 | ); |
||
153 | |||
154 | if (!empty($signature)) { |
||
155 | $response->setSignature($signature[0]); |
||
156 | $response->messageContainedSignatureUponConstruction = true; |
||
157 | } |
||
158 | |||
159 | return $response; |
||
160 | } |
||
179 |
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