| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 61 | 
| Code Lines | 55 | 
| 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  | 
            ||
| 150 | public function testAsyncBatchRequestWithMultipleChildren()  | 
            ||
| 151 |     { | 
            ||
| 152 | $idA = 123;  | 
            ||
| 153 | $idC = 'abc';  | 
            ||
| 154 | $idD = 'def';  | 
            ||
| 155 | $methodA = 'concat';  | 
            ||
| 156 | $methodB = 'nofify';  | 
            ||
| 157 | $methodC = 'sum';  | 
            ||
| 158 | $methodD = 'bar';  | 
            ||
| 159 | $paramsA = ['foo'=>'abc', 'bar'=>'def'];  | 
            ||
| 160 | $paramsB = ['foo'=>false];  | 
            ||
| 161 | $paramsC = ['foo'=>123, 'bar'=>456];  | 
            ||
| 162 | $paramsD = ['foo'=>123, 'bar'=>456];  | 
            ||
| 163 | $requestA = $this->client->request($idA, $methodA, $paramsA);  | 
            ||
| 164 | $requestB = $this->client->notification($methodB, $paramsB);  | 
            ||
| 165 | $requestC = $this->client->request($idC, $methodC, $paramsC);  | 
            ||
| 166 | $requestD = $this->client->request($idD, $methodD, $paramsD);  | 
            ||
| 167 | $promise = $this->client->sendAllAsync([$requestA, $requestB, $requestC, $requestD]);  | 
            ||
| 168 | |||
| 169 |         $promise->then(function ($responses) use ($requestA, $requestB, $requestC, $requestD, $idA, $idC, $idD, $methodA, $methodB, $methodC, $methodD, $paramsA, $paramsB, $paramsC, $paramsD) { | 
            ||
| 170 | $this->assertEquals(ClientInterface::SPEC, $requestA->getRpcVersion());  | 
            ||
| 171 | $this->assertEquals($idA, $requestA->getRpcId());  | 
            ||
| 172 | $this->assertEquals($methodA, $requestA->getRpcMethod());  | 
            ||
| 173 | $this->assertEquals($paramsA, $requestA->getRpcParams());  | 
            ||
| 174 | $this->assertEquals(ClientInterface::SPEC, $requestB->getRpcVersion());  | 
            ||
| 175 | $this->assertEquals(null, $requestB->getRpcId());  | 
            ||
| 176 | $this->assertEquals($methodB, $requestB->getRpcMethod());  | 
            ||
| 177 | $this->assertEquals($paramsB, $requestB->getRpcParams());  | 
            ||
| 178 | $this->assertEquals(ClientInterface::SPEC, $requestC->getRpcVersion());  | 
            ||
| 179 | $this->assertEquals($idC, $requestC->getRpcId());  | 
            ||
| 180 | $this->assertEquals($methodC, $requestC->getRpcMethod());  | 
            ||
| 181 | $this->assertEquals($paramsC, $requestC->getRpcParams());  | 
            ||
| 182 | $this->assertEquals(ClientInterface::SPEC, $requestD->getRpcVersion());  | 
            ||
| 183 | $this->assertEquals($idD, $requestD->getRpcId());  | 
            ||
| 184 | $this->assertEquals($methodD, $requestD->getRpcMethod());  | 
            ||
| 185 | $this->assertEquals($paramsD, $requestD->getRpcParams());  | 
            ||
| 186 | |||
| 187 | $this->assertTrue(is_array($responses));  | 
            ||
| 188 | $this->assertEquals(3, count($responses));  | 
            ||
| 189 | |||
| 190 | $responseA = $this->getResponseFromArray($responses, $idA);  | 
            ||
| 191 | $responseC = $this->getResponseFromArray($responses, $idC);  | 
            ||
| 192 | $responseD = $this->getResponseFromArray($responses, $idD);  | 
            ||
| 193 | |||
| 194 | $this->assertEquals(ClientInterface::SPEC, $responseA->getRpcVersion());  | 
            ||
| 195 |             $this->assertEquals(implode('', $paramsA), $responseA->getRpcResult()); | 
            ||
| 196 | $this->assertEquals($idA, $responseA->getRpcId());  | 
            ||
| 197 | $this->assertEquals(null, $responseA->getRpcErrorCode());  | 
            ||
| 198 | $this->assertEquals(null, $responseA->getRpcErrorMessage());  | 
            ||
| 199 | $this->assertEquals(ClientInterface::SPEC, $responseC->getRpcVersion());  | 
            ||
| 200 | $this->assertEquals(array_sum($paramsC), $responseC->getRpcResult());  | 
            ||
| 201 | $this->assertEquals($idC, $responseC->getRpcId());  | 
            ||
| 202 | $this->assertEquals(null, $responseC->getRpcErrorCode());  | 
            ||
| 203 | $this->assertEquals(null, $responseC->getRpcErrorMessage());  | 
            ||
| 204 | $this->assertEquals(ClientInterface::SPEC, $responseD->getRpcVersion());  | 
            ||
| 205 | $this->assertEquals(null, $responseD->getRpcResult());  | 
            ||
| 206 | $this->assertEquals($idD, $responseD->getRpcId());  | 
            ||
| 207 | $this->assertTrue(is_int($responseD->getRpcErrorCode()));  | 
            ||
| 208 | $this->assertTrue(is_string($responseD->getRpcErrorMessage()));  | 
            ||
| 209 | })->wait();  | 
            ||
| 210 | }  | 
            ||
| 211 | }  | 
            ||
| 212 | 
If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway: