| Conditions | 14 |
| Paths | 49 |
| Total Lines | 72 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 210 |
| 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 |
||
| 52 | public function execute(array $params) |
||
| 53 | { |
||
| 54 | $file = strtolower($this->argument('config', '')); |
||
| 55 | |||
| 56 | if ($file === '' || $file === '0') { |
||
| 57 | $this->fail('Vous devez spécifier la configuration à utiliser pour la vérification.')->eol(); |
||
| 58 | $this->write(' Usage: ' . $this->usage)->eol(); |
||
| 59 | $this->write('Exemple: config:check app')->eol(); |
||
| 60 | $this->write(' config:check \'BlitzPHP\Schild\Config\auth\''); |
||
| 61 | |||
| 62 | return EXIT_ERROR; |
||
| 63 | } |
||
| 64 | |||
| 65 | if (null === $config = config()->get($file)) { |
||
| 66 | $this->fail('Aucune configuration trouvée pour: ' . $file); |
||
| 67 | } |
||
| 68 | |||
| 69 | $this->center('Valeurs de la configuration ' . $this->color->ok($file)); |
||
| 70 | |||
| 71 | $this->border()->eol(); |
||
| 72 | |||
| 73 | $others = []; |
||
| 74 | |||
| 75 | foreach ($config as $key => $val) { |
||
| 76 | $options = ['fg' => Color::CYAN]; |
||
| 77 | |||
| 78 | if (is_scalar($val)) { |
||
| 79 | if (is_bool($val)) { |
||
| 80 | if ($val === true) { |
||
| 81 | $options['fg'] = Color::GREEN; |
||
| 82 | $val = 'Enabled'; |
||
| 83 | } else { |
||
| 84 | $options['fg'] = Color::YELLOW; |
||
| 85 | $val = 'Disabled'; |
||
| 86 | } |
||
| 87 | } elseif ('' === $val) { |
||
| 88 | $others[$key] = $val; |
||
| 89 | |||
| 90 | continue; |
||
| 91 | } |
||
| 92 | |||
| 93 | $this->justify($key, $val, ['second' => $options]); |
||
| 94 | } else { |
||
| 95 | if (($val = (array) $val) === []) { |
||
| 96 | $others[$key] = $val; |
||
| 97 | |||
| 98 | continue; |
||
| 99 | } |
||
| 100 | if (array_is_list($val)) { |
||
| 101 | $options = ['fg' => Color::PURPLE]; |
||
| 102 | $this->justify($key, implode(', ', array_values($val)), ['second' => $options]); |
||
| 103 | } else { |
||
| 104 | $others[$key] = $val; |
||
| 105 | |||
| 106 | continue; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | |||
| 111 | if ($others !== []) { |
||
| 112 | $this->eol()->task('Autres configuration')->eol(); |
||
| 113 | |||
| 114 | if (defined('KINT_DIR') && Kint::$enabled_mode !== false) { |
||
| 115 | $this->write($this->getKintDump($others)); |
||
| 116 | } else { |
||
| 117 | $this->write( |
||
| 118 | $this->color->line($this->getVarDump($others), ['fg' => Color::CYAN]) |
||
| 119 | ); |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | return EXIT_SUCCESS; |
||
| 124 | } |
||
| 160 |