Conditions | 12 |
Paths | 12 |
Total Lines | 80 |
Code Lines | 64 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
67 | public function handle() |
||
68 | { |
||
69 | if (empty($this->option('category'))) { |
||
70 | $qry = Release::query()->select(['id'])->get(); |
||
71 | $affected = 0; |
||
72 | $total = \count($qry); |
||
73 | if ($total > 0) { |
||
74 | $this->colorCli->header('Resetting all postprocessing'); |
||
75 | foreach ($qry as $releases) { |
||
76 | Release::query()->where('id', $releases->id)->update( |
||
77 | [ |
||
78 | 'consoleinfo_id' => null, |
||
79 | 'gamesinfo_id' => null, |
||
80 | 'imdbid' => null, |
||
81 | 'musicinfo_id' => null, |
||
82 | 'bookinfo_id' => null, |
||
83 | 'videos_id' => 0, |
||
84 | 'tv_episodes_id' => 0, |
||
85 | 'xxxinfo_id' => 0, |
||
86 | 'passwordstatus' => -1, |
||
87 | 'haspreview' => -1, |
||
88 | 'jpgstatus' => 0, |
||
89 | 'videostatus' => 0, |
||
90 | 'audiostatus' => 0, |
||
91 | 'nfostatus' => -1, |
||
92 | ] |
||
93 | ); |
||
94 | $this->consoleTools->overWritePrimary('Resetting Releases: '.$this->consoleTools->percentString(++$affected, $total)); |
||
95 | } |
||
96 | } else { |
||
97 | $this->colorCli->header('No releases to reset'); |
||
98 | } |
||
99 | } else { |
||
100 | foreach ($this->option('category') as $option) { |
||
101 | $adjusted = str_replace('=', '', $option); |
||
102 | if (\in_array($adjusted, self::$allowedCategories, false)) { |
||
103 | $this->info('Resetting postprocessing for '.$adjusted.' category'); |
||
104 | switch ($adjusted) { |
||
105 | case 'console': |
||
106 | $this->colorCli->header('Resetting all Console postprocessing'); |
||
107 | $qry = Release::query()->whereNotNull('consoleinfo_id')->whereBetween('categories_id', [Category::GAME_ROOT, Category::GAME_OTHER])->get(); |
||
108 | $total = $qry->count(); |
||
109 | $conCount = 0; |
||
110 | foreach ($qry as $releases) { |
||
111 | Release::query()->where('id', $releases->id)->update( |
||
112 | [ |
||
113 | 'consoleinfo_id' => null, |
||
114 | ]); |
||
115 | $this->consoleTools->overWritePrimary('Resetting Console Releases: '.$this->consoleTools->percentString(++$conCount, $total)); |
||
116 | } |
||
117 | $this->colorCli->header(number_format($conCount).' consoleinfo_id\'s reset.'); |
||
118 | break; |
||
119 | case 'movie': |
||
120 | $this->colorCli->header('Resetting all Movie postprocessing'); |
||
121 | $qry = Release::query()->whereNotNull('movieinfo_id')->whereBetween('categories_id', [Category::MOVIE_ROOT, Category::MOVIE_OTHER])->get(); |
||
122 | $total = $qry->count(); |
||
123 | $conCount = 0; |
||
124 | foreach ($qry as $releases) { |
||
125 | Release::query()->where('id', $releases->id)->update( |
||
126 | [ |
||
127 | 'movieinfo_id' => null, |
||
128 | ]); |
||
129 | $this->consoleTools->overWritePrimary('Resetting Movie Releases: '.$this->consoleTools->percentString(++$conCount, $total)); |
||
130 | } |
||
131 | $this->colorCli->header(number_format($conCount).' movieinfo_id\'s reset.'); |
||
132 | break; |
||
133 | case 'game': |
||
134 | $this->colorCli->header('Resetting all PC Games postprocessing'); |
||
135 | $qry = Release::query()->whereIn('gamesinfo_id', [-2, 0])->where('categories_id', '=', Category::PC_GAMES)->get(); |
||
136 | $total = $qry->count(); |
||
137 | $conCount = 0; |
||
138 | foreach ($qry as $releases) { |
||
139 | Release::query()->where('id', $releases->id)->update( |
||
140 | [ |
||
141 | 'gamesinfo_id' => null, |
||
142 | ]); |
||
143 | $this->consoleTools->overWritePrimary('Resetting PC GAME Releases: '.$this->consoleTools->percentString(++$conCount, $total)); |
||
144 | } |
||
145 | $this->colorCli->header(number_format($conCount).' gamesinfo_id\'s reset.'); |
||
146 | break; |
||
147 | } |
||
153 |