| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 42 |
| 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 |
||
| 142 | |||
| 143 | $agreementMethod = new AgreementMethod( |
||
| 144 | AnyURIValue::fromString(C::KEY_AGREEMENT_ECDH_ES), |
||
| 145 | $kaNonce, |
||
| 146 | $originatorKeyInfo, |
||
| 147 | $recipientKeyInfo, |
||
| 148 | [$digestMethod], |
||
| 149 | ); |
||
| 150 | |||
| 151 | $this->assertEquals( |
||
| 152 | self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
||
| 153 | strval($agreementMethod), |
||
| 154 | ); |
||
| 155 | } |
||
| 156 | |||
| 157 | |||
| 158 | public function testMarshallingElementOrdering(): void |
||
| 159 | { |
||
| 160 | $kaNonce = new KANonce( |
||
| 161 | Base64BinaryValue::fromString('/CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI='), |
||
| 162 | ); |
||
| 163 | |||
| 164 | $digestMethod = new DigestMethod( |
||
| 165 | AnyURIValue::fromString(C::DIGEST_SHA256), |
||
| 166 | [ |
||
| 167 | new Chunk(DOMDocumentFactory::fromString( |
||
| 168 | '<some:Chunk xmlns:some="urn:x-simplesamlphp:namespace">some</some:Chunk>', |
||
| 169 | )->documentElement), |
||
| 170 | ], |
||
| 171 | ); |
||
| 172 | |||
| 173 | $originatorKeyInfo = new OriginatorKeyInfo( |
||
| 174 | [ |
||
| 175 | new KeyName( |
||
| 176 | StringValue::fromString('testkey'), |
||
| 177 | ), |
||
| 178 | new X509Data( |
||
| 179 | [ |
||
| 180 | new X509Certificate( |
||
| 181 | Base64BinaryValue::fromString(self::$certificate), |
||
| 182 | ), |
||
| 183 | new X509SubjectName( |
||
| 184 | StringValue::fromString(self::$certData['name']), |
||
| 185 | ), |
||
| 186 | ], |
||
| 187 | ), |
||
| 188 | new Chunk(DOMDocumentFactory::fromString( |
||
| 189 | '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">originator</ssp:Chunk>', |
||
| 190 | )->documentElement), |
||
| 191 | ], |
||
| 192 | IDValue::fromString('fed321'), |
||
| 193 | ); |
||
| 194 | |||
| 195 | $recipientKeyInfo = new RecipientKeyInfo( |
||
| 196 | [ |
||
| 197 | new KeyName( |
||
| 198 | StringValue::fromString('testkey'), |
||
| 199 | ), |
||
| 200 | new X509Data( |
||
| 201 | [ |
||
| 202 | new X509Certificate( |
||
| 203 | Base64BinaryValue::fromString(self::$certificate), |
||
| 204 | ), |
||
| 205 | new X509SubjectName( |
||
| 206 | StringValue::fromString(self::$certData['name']), |
||
| 207 | ), |
||
| 208 | ], |
||
| 209 | ), |
||
| 210 | new Chunk(DOMDocumentFactory::fromString( |
||
| 211 | '<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">recipient</ssp:Chunk>', |
||
| 212 | )->documentElement), |
||
| 213 | ], |
||
| 214 | IDValue::fromString('fed654'), |
||
| 215 | ); |
||
| 216 | |||
| 217 | $agreementMethod = new AgreementMethod( |
||
| 249 |