Lines 66.66% 8 / 12
Methods 33.33% 1 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __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
10class 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}