| Conditions | 5 |
| Paths | 6 |
| Total Lines | 51 |
| Code Lines | 31 |
| 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 |
||
| 44 | public function handle() { |
||
| 45 | // Get start time |
||
| 46 | $start = microtime(true); |
||
| 47 | $not_used = 0; |
||
| 48 | $found_plain = 0; |
||
| 49 | $removed = 0; |
||
| 50 | |||
| 51 | $this->folders = TranslatorFacade::getConfigValue('search_folders'); |
||
| 52 | $this->extensions = TranslatorFacade::getConfigValue('search_extensions'); |
||
| 53 | |||
| 54 | $aFiles = $this->getAllIdentifier(); |
||
| 55 | |||
| 56 | $aDB = $this->loadFromDB(); |
||
| 57 | |||
| 58 | foreach ($aDB as $identifier) { |
||
| 59 | |||
| 60 | if (!in_array($identifier->identifier, $aFiles)) { |
||
| 61 | |||
| 62 | $found_as_plain = $this->verifyMissing($identifier->identifier); |
||
| 63 | |||
| 64 | $this->line(''); |
||
| 65 | |||
| 66 | if ($found_as_plain) { |
||
| 67 | $this->warn('\'' . $identifier->identifier . '\' was not found withing Translator directives'); |
||
| 68 | $found_plain++; |
||
| 69 | } else { |
||
| 70 | $this->line('\'' . $identifier->identifier . '\' seems to be not used anymore'); |
||
| 71 | $not_used++; |
||
| 72 | } |
||
| 73 | |||
| 74 | $task = $this->choice('What do you want me to do?', ['Nothing', 'Remove'], 0); |
||
| 75 | |||
| 76 | if ($task === 'Remove') { |
||
| 77 | $identifier->delete(); |
||
| 78 | Translations::where('translation_identifier_id', $identifier->id)->delete(); |
||
| 79 | $removed++; |
||
| 80 | } |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | $this->table(['Num', 'Identifier'], [ |
||
| 85 | [$this->found_identifier, "In DB"], |
||
| 86 | [$not_used, "Not Found"], |
||
| 87 | [$found_plain, "Found Plain"], |
||
| 88 | [$removed, "Removed"], |
||
| 89 | ]); |
||
| 90 | |||
| 91 | $this->info($not_used . ' Translations no longer used.'); |
||
| 92 | $this->line(''); |
||
| 93 | |||
| 94 | $this->info('Finished in: ' . number_format(microtime(true) - $start, 2) . 'sec'); |
||
| 95 | } |
||
| 217 |