| Conditions | 13 |
| Paths | 1 |
| Total Lines | 64 |
| Code Lines | 39 |
| 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 |
||
| 115 | protected function interact(InputInterface $input, OutputInterface $output) |
||
| 116 | { |
||
| 117 | $this->input = $input; |
||
| 118 | $this->output = $output; |
||
|
1 ignored issue
–
show
|
|||
| 119 | |||
| 120 | $project = $input->getArgument('project'); |
||
| 121 | |||
| 122 | if (empty($project) || !preg_match('/[a-z0-9_-]/i', $project)) { |
||
| 123 | throw new \InvalidArgumentException('Project argument is required and should only contain [a-z0-9_-]'); |
||
| 124 | } |
||
| 125 | |||
| 126 | $this->input->setOption('path', $this->prepareProjectPath()); |
||
| 127 | |||
| 128 | $this->git = new Git; |
||
| 129 | $inflector = new Inflector; |
||
| 130 | |||
| 131 | $this->output->writeln('<info>Phint Setup</info>'); |
||
| 132 | $this->output->writeln('<comment>Just press ENTER if you want to use the [default] or skip<comment>'); |
||
| 133 | $this->output->writeln(''); |
||
| 134 | |||
| 135 | $this->input->setOption('type', $this->input->getOption('type') ?: $this->prompt( |
||
| 136 | 'Project type (project/library)', |
||
| 137 | 'library', |
||
| 138 | ['project', 'library', 'composer-plugin'] |
||
| 139 | )); |
||
| 140 | |||
| 141 | $this->input->setOption('name', $this->input->getOption('name') ?: $this->prompt( |
||
| 142 | 'Vendor full name', |
||
| 143 | $this->git->getConfig('user.name') |
||
| 144 | )); |
||
| 145 | |||
| 146 | $this->input->setOption('email', $this->input->getOption('email') ?: $this->prompt( |
||
| 147 | 'Vendor email', |
||
| 148 | $this->git->getConfig('user.email') |
||
| 149 | )); |
||
| 150 | |||
| 151 | $this->input->setOption('description', $this->input->getOption('description') ?: $this->prompt( |
||
| 152 | 'Brief project description' |
||
| 153 | )); |
||
| 154 | |||
| 155 | $this->input->setOption('username', $username = $this->input->getOption('username') ?: $this->prompt( |
||
| 156 | 'Vendor handle (often github username)', |
||
| 157 | getenv('VENDOR_USERNAME') ?: null |
||
| 158 | )); |
||
| 159 | |||
| 160 | $namespace = $this->input->getOption('namespace') ?: $this->prompt( |
||
| 161 | 'Project root namespace (forward slashes are auto fixed)', |
||
| 162 | (getenv('VENDOR_NAMESPACE') ?: $inflector->stuldyCase($username)) |
||
| 163 | . '/' . $inflector->stuldyCase($project) |
||
| 164 | ); |
||
| 165 | |||
| 166 | $this->input->setOption('namespace', \str_replace('/', '\\\\', $namespace)); |
||
| 167 | |||
| 168 | $keywords = $this->input->getOption('keywords') ?: $this->prompt( |
||
| 169 | 'Project keywords (CSV)', |
||
| 170 | "php, $project" |
||
| 171 | ); |
||
| 172 | |||
| 173 | $this->input->setOption('keywords', array_map('trim', explode(',', $keywords))); |
||
|
1 ignored issue
–
show
|
|||
| 174 | |||
| 175 | $this->input->setOption('php', $this->input->getOption('php') ?: $this->prompt( |
||
| 176 | 'Minimum PHP version project needs', |
||
| 177 | PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, |
||
| 178 | ['5.4', '5.5', '5.6', '7.0', '7.1'] |
||
| 179 | )); |
||
| 192 |