Conditions | 9 |
Paths | 33 |
Total Lines | 54 |
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 |
||
41 | protected function execute(InputInterface $input, OutputInterface $output) |
||
42 | { |
||
43 | if (! class_exists('ZipArchive')) { |
||
44 | throw new RuntimeException('The Zip PHP extension is not installed. Please install it and try again.'); |
||
45 | } |
||
46 | |||
47 | $directory = ($input->getArgument('name')) ? getcwd().'/'.$input->getArgument('name') : getcwd(); |
||
48 | |||
49 | if (! $input->getOption('force')) { |
||
50 | $this->verifyApplicationDoesntExist($directory); |
||
51 | } |
||
52 | |||
53 | $output->writeln('<info>Crafting application...</info>'); |
||
54 | |||
55 | $version = $this->getVersion($input); |
||
56 | |||
57 | $this->download($zipFile = $this->makeFilename(), $version) |
||
58 | ->extract($zipFile, $directory) |
||
59 | ->prepareWritableDirectories($directory, $output) |
||
60 | ->cleanUp($zipFile); |
||
61 | |||
62 | $composer = $this->findComposer(); |
||
63 | |||
64 | $commands = [ |
||
65 | $composer.' install --no-scripts', |
||
66 | $composer.' run-script post-root-package-install', |
||
67 | $composer.' run-script post-create-project-cmd', |
||
68 | $composer.' run-script post-autoload-dump', |
||
69 | ]; |
||
70 | |||
71 | if ($input->getOption('no-ansi')) { |
||
72 | $commands = array_map(function ($value) { |
||
73 | return $value.' --no-ansi'; |
||
74 | }, $commands); |
||
75 | } |
||
76 | |||
77 | if ($input->getOption('quiet')) { |
||
78 | $commands = array_map(function ($value) { |
||
79 | return $value.' --quiet'; |
||
80 | }, $commands); |
||
81 | } |
||
82 | |||
83 | $process = new Process(implode(' && ', $commands), $directory, null, null, null); |
||
|
|||
84 | |||
85 | if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { |
||
86 | $process->setTty(true); |
||
87 | } |
||
88 | |||
89 | $process->run(function ($type, $line) use ($output) { |
||
90 | $output->write($line); |
||
91 | }); |
||
92 | |||
93 | $output->writeln('<comment>Application ready! Build something amazing.</comment>'); |
||
94 | } |
||
95 | |||
229 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: