| Conditions | 4 | 
| Paths | 8 | 
| Total Lines | 58 | 
| Code Lines | 27 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 1 | 
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 | ||
| 16 | public function runApp($requestData = null, array $values, $command) | ||
| 17 |     { | ||
| 18 | // Create a mock environment for testing with | ||
| 19 | $environment = Environment::mock( | ||
| 20 | [ | ||
| 21 | 'REQUEST_METHOD' => 'POST', | ||
| 22 | 'REQUEST_URI' => '/', | ||
| 23 | 'HTTP_CONTENT_TYPE' => 'application/json', | ||
| 24 | 'HTTP_X-Gitlab-Token' => 'alksjdljzcxl' | ||
| 25 | ] | ||
| 26 | ); | ||
| 27 | |||
| 28 | // Set up a request object based on the environment | ||
| 29 | $request = Request::createFromEnvironment($environment); | ||
| 30 | |||
| 31 | // Add request data, if it exists | ||
| 32 |         if (isset($requestData)) { | ||
| 33 | $request = $request->withParsedBody(json_decode($requestData, TRUE)); | ||
| 34 | } | ||
| 35 | |||
| 36 | // Set up a response object | ||
| 37 | $response = new Response(); | ||
| 38 | |||
| 39 | // Use the application settings | ||
| 40 | 		if ( ! defined('CONFIG_DIR')) { | ||
| 41 | 			define('CONFIG_DIR', __DIR__ . '/config'); | ||
| 42 | } | ||
| 43 | $settings = require __DIR__ . '/../../src/settings.php'; | ||
| 44 | |||
| 45 | // Instantiate the application | ||
| 46 | $app = new App($settings); | ||
| 47 | |||
| 48 | // Set up dependencies | ||
| 49 | require __DIR__ . '/../../src/dependencies.php'; | ||
| 50 | |||
| 51 | 		if ($command !== NULL) { | ||
| 52 | 			$app->getContainer()[Executor::class] = function (ContainerInterface $c) use ($values, $command) { | ||
|  | |||
| 53 | $mock = $this->getMockBuilder(Executor::class) | ||
| 54 | ->setMethods(['executeCommand']) | ||
| 55 | ->getMock(); | ||
| 56 | |||
| 57 | $mock->expects($this->once()) | ||
| 58 | 					->method('executeCommand') | ||
| 59 | ->with($this->equalTo($command), $this->equalTo($values)); | ||
| 60 | |||
| 61 | return $mock; | ||
| 62 | }; | ||
| 63 | } | ||
| 64 | |||
| 65 | // Register routes | ||
| 66 | require __DIR__ . '/../../src/routes.php'; | ||
| 67 | |||
| 68 | // Process the application | ||
| 69 | $response = $app->process($request, $response); | ||
| 70 | |||
| 71 | // Return the response | ||
| 72 | return $response; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.