| Conditions | 7 |
| Paths | 153 |
| Total Lines | 56 |
| Code Lines | 38 |
| 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 |
||
| 76 | protected function getDefaultCommands(): array |
||
| 77 | { |
||
| 78 | $commands = [ |
||
| 79 | new \Symfony\Component\Console\Command\HelpCommand(), |
||
| 80 | ]; |
||
| 81 | |||
| 82 | // Liste des commandes à charger depuis le container |
||
| 83 | $commandClasses = [ |
||
| 84 | 'Cecil\\Command\\About', |
||
| 85 | 'Cecil\\Command\\NewSite', |
||
| 86 | 'Cecil\\Command\\NewPage', |
||
| 87 | 'Cecil\\Command\\Edit', |
||
| 88 | 'Cecil\\Command\\Build', |
||
| 89 | 'Cecil\\Command\\Serve', |
||
| 90 | 'Cecil\\Command\\Clear', |
||
| 91 | 'Cecil\\Command\\CacheClear', |
||
| 92 | 'Cecil\\Command\\CacheClearAssets', |
||
| 93 | 'Cecil\\Command\\CacheClearTemplates', |
||
| 94 | 'Cecil\\Command\\CacheClearTranslations', |
||
| 95 | 'Cecil\\Command\\ShowContent', |
||
| 96 | 'Cecil\\Command\\ShowConfig', |
||
| 97 | 'Cecil\\Command\\ListCommand', |
||
| 98 | 'Cecil\\Command\\UtilTranslationsExtract', |
||
| 99 | ]; |
||
| 100 | |||
| 101 | foreach ($commandClasses as $commandClass) { |
||
| 102 | try { |
||
| 103 | // Instanciation directe car le container ne charge pas encore les services via resource |
||
| 104 | $class = str_replace('\\\\', '\\', $commandClass); |
||
| 105 | $command = new $class(); |
||
| 106 | if (method_exists($command, 'setContainer')) { |
||
| 107 | $command->setContainer($this->container); |
||
| 108 | } |
||
| 109 | $commands[] = $command; |
||
| 110 | } catch (\Exception $e) { |
||
| 111 | // Ignorer si la commande ne peut pas être instanciée |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | if (Util\Platform::isPhar()) { |
||
| 116 | try { |
||
| 117 | $command = new \Cecil\Command\SelfUpdate(); |
||
| 118 | $command->setContainer($this->container); |
||
| 119 | $commands[] = $command; |
||
| 120 | } catch (\Exception $e) { |
||
|
|
|||
| 121 | } |
||
| 122 | |||
| 123 | try { |
||
| 124 | $command = new \Cecil\Command\UtilTemplatesExtract(); |
||
| 125 | $command->setContainer($this->container); |
||
| 126 | $commands[] = $command; |
||
| 127 | } catch (\Exception $e) { |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | return $commands; |
||
| 132 | } |
||
| 134 |