Lines
66.66%
8 / 12
Functions and Methods
33.33%
1 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| CleanProcessArchivedToday | 66.66% | 8 / 12 | 33.33% | 1 / 3 | 7.33 | 0.00% | 0 / 1 | |||
| __construct | 33.33% | 1 / 3 | 0.00% | 0 / 1 | 3.19 | |||||
| log | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| startProcessing | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace BO\Zmsbackend\Helper; | |
| 6 | ||
| 7 | use BO\Zmsbackend\Process\Service\ProcessStatusArchived; | |
| 8 | use DateTimeInterface; | |
| 9 | ||
| 10 | class CleanProcessArchivedToday | |
| 11 | { | |
| 12 | protected $verbose = false; | |
| 13 | ||
| 14 | public function __construct(bool $verbose = false) | |
| 15 | { | |
| 16 | if ($verbose) { | |
| 17 | $this->verbose = true; | |
| 18 | $this->log("INFO: CleanProcessArchivedToday"); | |
| 19 | } | |
| 20 | } | |
| 21 | ||
| 22 | protected function log(string $message): void | |
| 23 | { | |
| 24 | if ($this->verbose) { | |
| 25 | \App::$log->info($message); | |
| 26 | } | |
| 27 | } | |
| 28 | ||
| 29 | public function startProcessing(bool $commit, DateTimeInterface $now): void | |
| 30 | { | |
| 31 | $logRepo = new ProcessStatusArchived(); | |
| 32 | if ($commit) { | |
| 33 | \App::$log->info('Executing archived process cleanup with commit', [ | |
| 34 | 'beforeDate' => $now->format('Y-m-d'), | |
| 35 | ]); | |
| 36 | $result = $logRepo->deleteBeforeDate($now); | |
| 37 | \App::$log->info('Archived process cleanup completed', ['success' => $result]); | |
| 38 | } | |
| 39 | } | |
| 40 | } |