Lines 0.00% 0 / 8
Functions and Methods 0.00% 0 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
EventLogCleanUpByCron 0.00% 0 / 8 0.00% 0 / 3 42 0.00% 0 / 1
 __construct 0.00% 0 / 3 0.00% 0 / 1 6
 log 0.00% 0 / 2 0.00% 0 / 1 6
 startProcessing 0.00% 0 / 3 0.00% 0 / 1 6
1<?php
2
3/**
4 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
5 **/
6
7declare(strict_types=1);
8
9namespace BO\Zmsbackend\Helper;
10
11use BO\Zmsbackend\EventLog\Service\EventLog as EventLogRepository;
12
13class EventLogCleanUpByCron
14{
15    protected $verbose = false;
16
17    public function __construct(bool $verbose = false)
18    {
19        if ($verbose) {
20            $this->verbose = true;
21            $this->log("INFO: Delete old eventlog entries");
22        }
23    }
24
25    protected function log(string $message): void
26    {
27        if ($this->verbose) {
28            \App::$log->info($message);
29        }
30    }
31
32    public static function startProcessing(bool $commit = false): void
33    {
34        $eventLogRepo  = new EventLogRepository();
35        if ($commit) {
36            $eventLogRepo->deleteOutdated();
37        }
38    }
39}