Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CleanLogsCommand
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 getAllowedAppEnvs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 handle
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3namespace Olz\Command;
4
5use Olz\Apps\Logs\Utils\DailyFileLogsChannel;
6use Olz\Apps\Logs\Utils\LogsDefinitions;
7use Olz\Command\Common\OlzCommand;
8use Symfony\Component\Console\Attribute\AsCommand;
9use Symfony\Component\Console\Command\Command;
10use Symfony\Component\Console\Input\InputInterface;
11use Symfony\Component\Console\Output\OutputInterface;
12
13#[AsCommand(name: 'olz:clean-logs')]
14class CleanLogsCommand extends OlzCommand {
15    /** @return array<string> */
16    protected function getAllowedAppEnvs(): array {
17        return ['dev', 'test', 'staging', 'prod'];
18    }
19
20    protected function handle(InputInterface $input, OutputInterface $output): int {
21        $channels = LogsDefinitions::getLogsChannels();
22        foreach ($channels as $channel) {
23            if ($channel instanceof DailyFileLogsChannel) {
24                $channel->optimizeHybridFiles();
25                $channel->cleanUpOldFiles();
26            }
27        }
28        return Command::SUCCESS;
29    }
30}