| Conditions | 9 |
| Paths | 111 |
| Total Lines | 71 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 83 | protected function executeJobs(OutputInterface $output) { |
||
| 84 | |||
| 85 | $jobs = $this->getCronJobs(); |
||
| 86 | |||
| 87 | /* |
||
| 88 | * Минимально допустимый период выполнения одной задачи |
||
| 89 | * при котором гарантируется выполнение всех задач |
||
| 90 | */ |
||
| 91 | $this->minAgentPeriod = (count($jobs) + 1) * EnvHelper::getBxCrontabPeriod(); |
||
| 92 | |||
| 93 | if(!empty($jobs)) { |
||
| 94 | |||
| 95 | foreach($jobs as $cmd => $job) { |
||
| 96 | |||
| 97 | if($this->isActualJob($job)) { |
||
| 98 | |||
| 99 | $job['status'] = self::EXEC_STATUS_WORK; |
||
| 100 | $this->updaateJob($cmd, $job); |
||
| 101 | |||
| 102 | $command = $this->getApplication()->find($cmd); |
||
| 103 | $cmdInput = new ArrayInput(['command' => $cmd]); |
||
| 104 | try { |
||
| 105 | |||
| 106 | $timeStart = microtime(true); |
||
| 107 | $returnCode = $command->run($cmdInput, $output); |
||
| 108 | |||
| 109 | if(!$returnCode) { |
||
| 110 | |||
| 111 | $job['status'] = self::EXEC_STATUS_SUCCESS; |
||
| 112 | |||
| 113 | $msg = sprintf("%s: SUCCESS [%.2f s]", $cmd, microtime(true) - $timeStart); |
||
| 114 | if($this->logger) { |
||
| 115 | $this->logger->alert($msg); |
||
| 116 | } |
||
| 117 | $output->writeln(PHP_EOL . $msg); |
||
| 118 | |||
| 119 | } else { |
||
| 120 | |||
| 121 | $job['status'] = self::EXEC_STATUS_ERROR; |
||
| 122 | $job['error_code'] = $returnCode; |
||
| 123 | |||
| 124 | $msg = sprintf("%s: ERROR [%.2f s]", $cmd, microtime(true) - $timeStart); |
||
| 125 | if($this->logger) { |
||
| 126 | $this->logger->alert($msg); |
||
| 127 | } |
||
| 128 | $output->writeln(PHP_EOL . $msg); |
||
| 129 | } |
||
| 130 | |||
| 131 | } catch (\Exception $e) { |
||
| 132 | |||
| 133 | $job['status'] = self::EXEC_STATUS_ERROR; |
||
| 134 | $job['error'] = $e->getMessage(); |
||
| 135 | |||
| 136 | |||
| 137 | if($this->logger) { |
||
| 138 | $this->logger->error($e, ['command' => $cmd]); |
||
| 139 | } |
||
| 140 | $output->writeln(PHP_EOL . 'ERROR: ' . $e->getMessage()); |
||
| 141 | |||
| 142 | } finally { |
||
| 143 | |||
| 144 | $job['last_exec'] = time(); |
||
| 145 | $humanDate = new DateTime(); |
||
| 146 | $job['last_date_time'] = $humanDate->toString(); |
||
| 147 | } |
||
| 148 | |||
| 149 | $this->updaateJob($cmd, $job); |
||
| 150 | /* |
||
| 151 | * Let's do just one task |
||
| 152 | */ |
||
| 153 | break; |
||
| 154 | } |
||
| 279 | } |
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