| Conditions | 11 |
| Paths | 13 |
| Total Lines | 41 |
| Code Lines | 23 |
| 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 |
||
| 55 | protected function initialize(InputInterface $input, OutputInterface $output) |
||
| 56 | { |
||
| 57 | $this->input = $input; |
||
| 58 | $this->output = $output; |
||
| 59 | $this->io = new SymfonyStyle($input, $output); |
||
| 60 | $this->fs = new Filesystem(); |
||
| 61 | |||
| 62 | if (!in_array($this->getName(), ['self-update'])) { |
||
| 63 | // working directory |
||
| 64 | $this->path = getcwd(); |
||
| 65 | if ($input->getArgument('path') !== null) { |
||
| 66 | $this->path = (string) $input->getArgument('path'); |
||
| 67 | } |
||
| 68 | if (realpath($this->getPath()) === false) { |
||
| 69 | $this->fs->mkdir($this->getPath()); |
||
| 70 | } |
||
| 71 | $this->path = realpath($this->getPath()); |
||
| 72 | // config file(s) |
||
| 73 | if (!in_array($this->getName(), ['new:site'])) { |
||
| 74 | // default |
||
| 75 | $this->configFiles[self::CONFIG_FILE] = realpath(Util::joinFile($this->getPath(), self::CONFIG_FILE)); |
||
| 76 | // from --config=<file> |
||
| 77 | if ($input->hasOption('config') && $input->getOption('config') !== null) { |
||
| 78 | foreach (explode(',', (string) $input->getOption('config')) as $configFile) { |
||
| 79 | $this->configFiles[$configFile] = realpath($configFile); |
||
| 80 | if (!Util\File::getFS()->isAbsolutePath($configFile)) { |
||
| 81 | $this->configFiles[$configFile] = realpath(Util::joinFile($this->getPath(), $configFile)); |
||
| 82 | } |
||
| 83 | } |
||
| 84 | } |
||
| 85 | // checks file(s) |
||
| 86 | foreach ($this->configFiles as $fileName => $filePath) { |
||
| 87 | if (!file_exists($filePath)) { |
||
| 88 | $this->getBuilder()->getLogger()->error(\sprintf('Could not find configuration file "%s": uses default/others.', $fileName)); |
||
| 89 | unset($this->configFiles[$fileName]); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | parent::initialize($input, $output); |
||
| 96 | } |
||
| 203 |