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