| Conditions | 9 |
| Paths | 52 |
| Total Lines | 64 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 3 | 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 |
||
| 79 | private function processInputs(InputInterface $input) |
||
| 80 | { |
||
| 81 | $this->environment = $input->getOption('env'); |
||
| 82 | $this->systemEnvironment = $input->getOption('system'); |
||
| 83 | |||
| 84 | if($input->getOption('dry-run')) |
||
| 85 | { |
||
| 86 | $this->dryRun = true; |
||
| 87 | $this->output->writeln("<fg=cyan>Run in dry-run mode</fg=cyan>"); |
||
| 88 | } |
||
| 89 | |||
| 90 | if($input->getOption('backup')) |
||
| 91 | { |
||
| 92 | $this->isBackupEnabled = true; |
||
| 93 | $this->output->writeln("<fg=cyan>Backup enabled</fg=cyan>"); |
||
| 94 | } |
||
| 95 | |||
| 96 | $profile = $this->app['profile']; |
||
| 97 | $sourcePath = $input->getArgument('sourcePath'); |
||
| 98 | if(empty($sourcePath)) |
||
| 99 | { |
||
| 100 | if($profile->hasSourcePath() !== true) |
||
| 101 | { |
||
| 102 | throw new \RuntimeException('Missing argument sourcePath'); |
||
| 103 | } |
||
| 104 | |||
| 105 | $sourcePath = $profile->getSourcePath(); |
||
| 106 | } |
||
| 107 | |||
| 108 | if(! is_array($sourcePath)) |
||
| 109 | { |
||
| 110 | $sourcePath = array($sourcePath); |
||
| 111 | } |
||
| 112 | |||
| 113 | $targetPath = $input->getOption('targetPath'); |
||
| 114 | |||
| 115 | if(is_array($targetPath)) |
||
| 116 | { |
||
| 117 | throw new \RuntimeException('Invalid argument targetPath : could not be mutiple (single path required as string)'); |
||
| 118 | } |
||
| 119 | |||
| 120 | if(empty($targetPath) && $profile->hasTargetPath() === true) |
||
| 121 | { |
||
| 122 | $targetPath = $profile->getTargetPath(); |
||
| 123 | } |
||
| 124 | |||
| 125 | $this->output->writeln(sprintf( |
||
| 126 | "<info>%s <comment>%s</comment> with <comment>%s</comment> values</info>", |
||
| 127 | $this->outputTitle, |
||
| 128 | implode(' ', $sourcePath), |
||
| 129 | $this->environment |
||
| 130 | )); |
||
| 131 | $this->output->writeln(''); |
||
| 132 | |||
| 133 | $this->app['sources.path'] = $sourcePath; |
||
| 134 | $this->app['target.path'] = $targetPath; |
||
| 135 | |||
| 136 | $this->processOverridenVariables( |
||
| 137 | $this->parseOptionWithAssignments($input, 'override') |
||
| 138 | ); |
||
| 139 | $this->processCustomData( |
||
| 140 | $this->parseOptionWithAssignments($input, 'data') |
||
| 141 | ); |
||
| 142 | } |
||
| 143 | |||
| 242 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.