Conditions | 6 |
Paths | 40 |
Total Lines | 92 |
Code Lines | 65 |
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 |
||
134 | protected function execute(InputInterface $input, OutputInterface $output) |
||
135 | { |
||
136 | $fromDate = \DateTime::createFromFormat('Y-m-d H:i:s', $input->getOption('from').' 00:00:00'); |
||
137 | $fromDate->setTimezone(new \DateTimeZone('UTC')); |
||
138 | $this->config->setParameter('start_datetime', $fromDate); |
||
139 | |||
140 | $toDate = \DateTime::createFromFormat('Y-m-d H:i:s', $input->getOption('to').' 00:00:00'); |
||
141 | $toDate->setTimezone(new \DateTimeZone('UTC')); |
||
142 | $this->config->setParameter('end_datetime', $toDate); |
||
143 | |||
144 | $progress = new ProgressBar($output, 40); |
||
145 | $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%\n\n"); |
||
146 | $progress->setMessage('Starting...'); |
||
147 | $progress->setProgressCharacter("\xF0\x9F\x8D\xBA"); |
||
148 | |||
149 | if (!$this->auth->isValid()) { |
||
150 | $helper = $this->getHelper('question'); |
||
151 | |||
152 | $question = new Question($this->auth->getError()."\n\n". |
||
153 | "Enter user access token from the Graph API Explorer\n". |
||
154 | "https://developers.facebook.com/tools/explorer\n"); |
||
155 | $auth = $this->auth; |
||
156 | $question->setValidator(function ($token) use ($auth) { |
||
157 | if (trim($token) == '') { |
||
158 | throw new \Exception('The token can not be empty'); |
||
159 | } |
||
160 | |||
161 | $auth->setToken($token); |
||
162 | |||
163 | if (!$auth->isValid()) { |
||
164 | throw new \Exception($auth->getError()); |
||
165 | } |
||
166 | |||
167 | return $token; |
||
168 | }); |
||
169 | |||
170 | $question->setHidden(true); |
||
171 | $question->setMaxAttempts(20); |
||
172 | |||
173 | $helper->ask($input, $output, $question); |
||
174 | } |
||
175 | |||
176 | $output->writeln('Generating report from '.$this->config->getParameter('start_datetime')->format('c').' to '.$this->config->getParameter('end_datetime')->format('c')."\n"); |
||
177 | $progress->start(); |
||
178 | $progress->setMessage('Setting up Facebook service...'); |
||
179 | $progress->advance(); |
||
180 | |||
181 | try { |
||
182 | $fetcher = new Fetcher($this->config, $progress, $this->auth->fb); |
||
183 | $mapper = new Mapper($this->config, $fetcher->getFeed()); |
||
184 | $topics = $mapper->getTopics(); |
||
185 | $comments = $mapper->getComments(); |
||
186 | $replies = $mapper->getReplies(); |
||
187 | $users = $mapper->getUsers(); |
||
188 | $newMembers = $fetcher->getNewMembers(); |
||
189 | |||
190 | $progress->advance(); |
||
191 | |||
192 | $progress->finish(); |
||
193 | $output->writeln("\n"); |
||
194 | |||
195 | $start = $this->config->getParameter('start_datetime'); |
||
196 | $start->setTimezone(new \DateTimeZone(date_default_timezone_get())); |
||
197 | |||
198 | $end = $this->config->getParameter('end_datetime'); |
||
199 | $end->setTimezone(new \DateTimeZone(date_default_timezone_get())); |
||
200 | |||
201 | $output->writeln($this->template->render([ |
||
202 | 'translator' => $this->translator, |
||
203 | 'start_date' => $start->format('Y-m-d'), |
||
204 | 'end_date' => $end->format('Y-m-d'), |
||
205 | 'new_members' => count($newMembers), |
||
206 | 'top_members' => $this->config->getParameter('top_users_count'), |
||
207 | 'banned_count' => $this->config->getParameter('new_blocked_count') - $this->config->getParameter('last_blocked_count'), |
||
208 | 'topics' => $topics, |
||
209 | 'active_members' => $users->count(), |
||
210 | 'new_comments' => $comments->count(), |
||
211 | 'new_replies' => $replies->count(), |
||
212 | 'top_users' => $users->getTopUsers($this->config->getParameter('top_users_count'), $this->config->getParameter('ignored_users')), |
||
213 | 'commits_count' => 3, |
||
214 | 'top_topics' => $this->config->getParameter('top_topics'), |
||
215 | 'group_id' => $this->config->getParameter('group_id') |
||
216 | ])); |
||
217 | |||
218 | $this->generateReports($users, $topics, $newMembers); |
||
219 | |||
220 | if ($input->getOption('animation')) { |
||
221 | $this->generateGourceLog($topics, $comments, $replies); |
||
222 | } |
||
223 | |||
224 | } catch (\Exception $e) { |
||
225 | $output->writeln($e->getMessage()); |
||
226 | } |
||
317 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths