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