events/Classes/Service/CleanupService.php

39 lines
761 B
PHP
Raw Normal View History

2019-08-12 07:43:37 +02:00
<?php
namespace Wrm\Events\Service;
use Wrm\Events\Service\Cleanup\Database;
use Wrm\Events\Service\Cleanup\Files;
class CleanupService
{
/**
* @var Database
*/
private $database;
/**
* @var Files
*/
private $files;
public function __construct(Database $database, Files $files)
{
$this->database = $database;
$this->files = $files;
}
public function deleteAllData(): void
{
$this->database->truncateTables();
$this->files->deleteAll();
}
public function deletePastData(): void
{
$this->database->deleteDates(...$this->database->getPastDates());
$this->database->deleteEventsWithoutDates();
$this->files->deleteDangling();
}
}