| Conditions | 3 | 
| Paths | 4 | 
| Total Lines | 76 | 
| Code Lines | 54 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 12 | 
| 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  | 
            ||
| 75 | protected function execute(InputInterface $input, OutputInterface $output)  | 
            ||
| 
                                                                                                    
                         1 ignored issue 
                            –
                            show
                         | 
                |||
| 76 |     { | 
            ||
| 77 |         $template = $input->getOption('template'); | 
            ||
| 78 |         $directory = $input->getOption('directory'); | 
            ||
| 79 |         $file = $input->getOption('filename'); | 
            ||
| 80 | $params = [];  | 
            ||
| 81 | |||
| 82 |         if ($template === null) { | 
            ||
| 83 | $io = new SymfonyStyle($input, $output);  | 
            ||
| 84 |             $helper = $this->getHelper('question'); | 
            ||
| 85 |             $formatter = $this->getHelper('formatter'); | 
            ||
| 86 | |||
| 87 | // Welcome message  | 
            ||
| 88 | $output->writeln([  | 
            ||
| 89 | '',  | 
            ||
| 90 |                 $formatter->formatBlock('Welcome to the Deployer config generator', 'bg=blue;fg=white', true), | 
            ||
| 91 | '',  | 
            ||
| 92 | ]);  | 
            ||
| 93 | |||
| 94 | $io->text([  | 
            ||
| 95 | 'This utility will walk you through creating a deploy.php file.',  | 
            ||
| 96 | 'It only covers the most common items, and tries to guess sensible defaults.',  | 
            ||
| 97 | '',  | 
            ||
| 98 | 'Press ^C at any time to quit.',  | 
            ||
| 99 | ]);  | 
            ||
| 100 | |||
| 101 | // Project type  | 
            ||
| 102 |             $template = $io->choice('Please select your project type', $this->availableTemplates, 'Common'); | 
            ||
| 103 | |||
| 104 | // Repo  | 
            ||
| 105 | $default = false;  | 
            ||
| 106 |             try { | 
            ||
| 107 |                 $default = (new Process('git remote get-url origin')) | 
            ||
| 108 | ->mustRun()  | 
            ||
| 109 | ->getOutput();  | 
            ||
| 110 | $default = trim($default);  | 
            ||
| 111 |             } catch (RuntimeException $e) { | 
            ||
| 112 | // pass  | 
            ||
| 113 | }  | 
            ||
| 114 |             $params['repository'] = $io->ask('Repository', $default); | 
            ||
| 115 | |||
| 116 | // Privacy  | 
            ||
| 117 | $io->text([  | 
            ||
| 118 | 'Contribute to the Deployer Development',  | 
            ||
| 119 | '',  | 
            ||
| 120 | 'In order to help development and improve Deployer features in,',  | 
            ||
| 121 | 'Deployer has a setting for collection of usage data. This function',  | 
            ||
| 122 | 'collects anonymous usage data and sends it to Deployer. The data is',  | 
            ||
| 123 | 'used in Deployer development to get reliable statistics on which',  | 
            ||
| 124 | 'features are used (or not used). The information is not traceable',  | 
            ||
| 125 | 'to any individual or organization. Participation is voluntary,',  | 
            ||
| 126 | 'and you can change your mind at any time.',  | 
            ||
| 127 | '',  | 
            ||
| 128 | 'Anonymous usage data contains Deployer version, php version, os type,',  | 
            ||
| 129 | 'name of the command being executed and whether it was successful or not,',  | 
            ||
| 130 | 'exception class name, count of hosts and anonymized project hash.',  | 
            ||
| 131 | '',  | 
            ||
| 132 | 'If you would like to allow us to gather this information and help',  | 
            ||
| 133 | 'us develop a better tool, please add the code below.',  | 
            ||
| 134 | '',  | 
            ||
| 135 | " <fg=white>set(<fg=cyan>'allow_anonymous_stats'</fg=cyan>, <fg=magenta;options=bold>true</fg=magenta;options=bold>);</fg=white>",  | 
            ||
| 136 | '',  | 
            ||
| 137 | 'This function will not affect the performance of Deployer as',  | 
            ||
| 138 | 'the data is insignificant and transmitted in separate process.',  | 
            ||
| 139 | ]);  | 
            ||
| 140 | |||
| 141 |             $params['allow_anonymous_stats'] = $GLOBALS['allow_anonymous_stats'] = $io->confirm('Do you confirm?'); | 
            ||
| 142 | }  | 
            ||
| 143 | |||
| 144 | $filePath = $this->initializer->initialize($template, $directory, $file, $params);  | 
            ||
| 145 | |||
| 146 | $output->writeln(sprintf(  | 
            ||
| 147 | '<info>Successfully created:</info> <comment>%s</comment>',  | 
            ||
| 148 | $filePath  | 
            ||
| 149 | ));  | 
            ||
| 150 | }  | 
            ||
| 151 | |||
| 175 | 
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: