| Conditions | 5 |
| Paths | 8 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 2 | public function run(SchedulerInterface $scheduler, DateTimeInterface $from, DateTimeInterface $to = null, $inc = true) |
|
| 34 | { |
||
| 35 | 2 | $actionsIterator = $scheduler->getIterator($from, $to, $inc); |
|
| 36 | 2 | $reports = []; |
|
| 37 | 2 | foreach ($actionsIterator as $action) { |
|
| 38 | try { |
||
| 39 | 2 | if ($this->actionLog === null) { |
|
| 40 | 2 | $reports[] = new Report($action, $action()); |
|
| 41 | 1 | } else if ($this->actionLog->update($action)) { |
|
| 42 | 1 | $reports[] = new Report($action, $action()); |
|
| 43 | 1 | $this->actionLog->update($action); |
|
| 44 | 2 | } else { |
|
| 45 | //action already executed or taken by another worker |
||
| 46 | } |
||
| 47 | 1 | } catch (\Exception $e) { |
|
| 48 | 2 | $reports[] = new Report($action, $e, Report::TYPE_ERROR); |
|
| 49 | } |
||
| 50 | } |
||
| 51 | 2 | return $reports; |
|
| 52 | } |
||
| 53 | } |