| Conditions | 13 |
| Paths | 1 |
| Total Lines | 68 |
| Code Lines | 41 |
| 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->loadConfig($this->input->getOption('config')); |
||
| 127 | |||
| 128 | $this->input->setOption('path', $path = $this->prepareProjectPath()); |
||
| 129 | |||
| 130 | $this->git = (new Git)->withOutput($this->output)->withWorkDir($path); |
||
| 131 | $this->composer = (new Composer)->withOutput($this->output)->withWorkDir($path); |
||
| 132 | |||
| 133 | $this->output->writeln('<info>Phint Setup</info>'); |
||
| 134 | $this->output->writeln('<comment>Just press ENTER if you want to use the [default] or skip<comment>'); |
||
| 135 | $this->output->writeln(''); |
||
| 136 | |||
| 137 | $this->input->setOption('type', $this->input->getOption('type') ?: $this->prompt( |
||
| 138 | 'Project type (project/library)', |
||
| 139 | 'library', |
||
| 140 | ['project', 'library', 'composer-plugin'] |
||
| 141 | )); |
||
| 142 | |||
| 143 | $this->input->setOption('name', $this->input->getOption('name') ?: $this->prompt( |
||
| 144 | 'Vendor full name', |
||
| 145 | $this->git->getConfig('user.name') |
||
| 146 | )); |
||
| 147 | |||
| 148 | $this->input->setOption('email', $this->input->getOption('email') ?: $this->prompt( |
||
| 149 | 'Vendor email', |
||
| 150 | $this->git->getConfig('user.email') |
||
| 151 | )); |
||
| 152 | |||
| 153 | $this->input->setOption('description', $this->input->getOption('description') ?: $this->prompt( |
||
| 154 | 'Brief project description' |
||
| 155 | )); |
||
| 156 | |||
| 157 | $this->input->setOption('username', $username = $this->input->getOption('username') ?: $this->prompt( |
||
| 158 | 'Vendor handle (often github username)', |
||
| 159 | getenv('VENDOR_USERNAME') ?: null |
||
| 160 | )); |
||
| 161 | |||
| 162 | $inflector = new Inflector; |
||
| 163 | |||
| 164 | $namespace = $this->input->getOption('namespace') ?: $this->prompt( |
||
| 165 | 'Project root namespace (forward slashes are auto fixed)', |
||
| 166 | (getenv('VENDOR_NAMESPACE') ?: $inflector->stuldyCase($username)) |
||
| 167 | . '/' . $inflector->stuldyCase($project) |
||
| 168 | ); |
||
| 169 | |||
| 170 | $this->input->setOption('namespace', \str_replace('/', '\\\\', $namespace)); |
||
| 171 | |||
| 172 | $keywords = $this->input->getOption('keywords') ?: $this->prompt( |
||
| 173 | 'Project keywords (CSV)', |
||
| 174 | "php, $project" |
||
| 175 | ); |
||
| 176 | |||
| 177 | $this->input->setOption('keywords', array_map('trim', explode(',', $keywords))); |
||
|
1 ignored issue
–
show
|
|||
| 178 | |||
| 179 | $this->input->setOption('php', floatval($this->input->getOption('php') ?: $this->prompt( |
||
| 180 | 'Minimum PHP version project needs', |
||
| 181 | PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, |
||
| 182 | ['5.4', '5.5', '5.6', '7.0', '7.1'] |
||
| 183 | ))); |
||
| 233 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..