| Conditions | 11 |
| Paths | 16 |
| Total Lines | 38 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 93 | public function execute(array $params) |
||
| 94 | { |
||
| 95 | $options = [ |
||
| 96 | 'php' => PHP_BINARY, |
||
| 97 | 'host' => 'localhost', |
||
| 98 | 'port' => 3300, |
||
| 99 | ]; |
||
| 100 | |||
| 101 | if (isset($this->options['--php'])) { |
||
| 102 | $options['php'] = $this->options['--php'][1] ?? PHP_BINARY; |
||
| 103 | } |
||
| 104 | if (isset($this->options['--host'])) { |
||
| 105 | $options['host'] = $this->options['--host'][1] ?? 'localhost'; |
||
| 106 | } |
||
| 107 | if (isset($this->options['--port'])) { |
||
| 108 | $options['port'] = $this->options['--port'][1] ?? 3300; |
||
| 109 | } |
||
| 110 | |||
| 111 | $php = escapeshellarg($params['php'] ?: $options['php']); |
||
| 112 | $host = $params['host'] ?: $options['host']; |
||
| 113 | $port = (int) ($params['port'] ?: $options['port']) + $this->portOffset; |
||
| 114 | |||
| 115 | $this->task($this->taskMessages['demarrage'] ?: 'Demarrage du serveur de developpement'); |
||
| 116 | sleep(2); |
||
| 117 | |||
| 118 | $this->io->ok($this->taskMessages['demarrer'] ?: 'Le serveur de développement BlitzPHP a démarré sur '); |
||
| 119 | $this->writer->boldGreen('http://' . $host . ':' . $port, true); |
||
| 120 | $this->write("Appuyez sur Control-C pour arrêter.\n", true); |
||
| 121 | |||
| 122 | // Appelez le serveur Web intégré de PHP, en veillant à définir notre |
||
| 123 | // chemin de base vers le dossier public et pour utiliser le fichier de réécriture |
||
| 124 | // pour s'assurer que notre environnement est défini et qu'il simule le mod_rewrite de base. |
||
| 125 | passthru($php . ' -S ' . $host . ':' . $port . ' -t ' . escapeshellarg($this->rootDirectory), $status); |
||
| 126 | |||
| 127 | if ($status && $this->portOffset < $this->tries) { |
||
| 128 | $this->portOffset++; |
||
| 129 | |||
| 130 | $this->execute($params); |
||
| 131 | } |
||
| 134 |