| Conditions | 11 |
| Paths | 1 |
| Total Lines | 34 |
| 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 |
||
| 20 | function artisan($command, $options = []) |
||
| 21 | { |
||
| 22 | return function () use ($command, $options) { |
||
| 23 | $versionTooEarly = array_key_exists('min', $options) |
||
| 24 | && laravel_version_compare($options['min'], '<'); |
||
| 25 | |||
| 26 | $versionTooLate = array_key_exists('max', $options) |
||
| 27 | && laravel_version_compare($options['max'], '>'); |
||
| 28 | |||
| 29 | if ($versionTooEarly || $versionTooLate) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (in_array('failIfNoEnv', $options) && ! test('[ -s {{release_path}}/.env ]')) { |
||
| 34 | throw new \Exception('Your .env file is empty! Cannot proceed.'); |
||
| 35 | } |
||
| 36 | |||
| 37 | if (in_array('skipIfNoEnv', $options) && ! test('[ -s {{release_path}}/.env ]')) { |
||
| 38 | writeln('<fg=yellow;options=bold;>Warning: </><fg=yellow;>Your .env file is empty! Skipping...</>'); |
||
| 39 | |||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | $artisan = in_array('runInCurrent', $options) |
||
|
|
|||
| 44 | ? '{{deploy_path}}/current/artisan' |
||
| 45 | : '{{release_path}}/artisan'; |
||
| 46 | |||
| 47 | $output = run("{{bin/php}} {{release_path}}/artisan $command"); |
||
| 48 | |||
| 49 | if (in_array('showOutput', $options)) { |
||
| 50 | writeln("<info>$output</info>"); |
||
| 51 | } |
||
| 52 | }; |
||
| 53 | } |
||
| 54 | |||
| 75 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.