• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / cpanel-requests / 12019847339

25 Nov 2024 08:30PM UTC coverage: 99.497%. Remained the same
12019847339

push

github

web-flow
[TASK] Update eliashaeussler/php-cs-fixer-config to v2.2.1

| datasource | package                            | from  | to    |
| ---------- | ---------------------------------- | ----- | ----- |
| packagist  | eliashaeussler/php-cs-fixer-config | 2.2.0 | 2.2.1 |

396 of 398 relevant lines covered (99.5%)

9.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/Command/CleanupCookiesCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/cpanel-requests".
7
 *
8
 * Copyright (C) 2020-2024 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\CpanelRequests\Command;
25

26
use EliasHaeussler\CpanelRequests\Resource;
27
use Symfony\Component\Console;
28

29
use function array_map;
30
use function count;
31
use function is_numeric;
32

33
/**
34
 * CleanupCookiesCommand.
35
 *
36
 * @author Elias Häußler <elias@haeussler.dev>
37
 * @license GPL-3.0-or-later
38
 */
39
final class CleanupCookiesCommand extends Console\Command\Command
40
{
41
    protected function configure(): void
5✔
42
    {
43
        $this
5✔
44
            ->setName('cleanup:cookies')
5✔
45
            ->setDescription('Clear cookie files')
5✔
46
            ->setHelp('This command clears cookie files whose lifetime has expired.')
5✔
47
        ;
5✔
48

49
        $this->addOption(
5✔
50
            'lifetime',
5✔
51
            'l',
5✔
52
            Console\Input\InputOption::VALUE_REQUIRED,
5✔
53
            'Lifetime of cookie files in seconds',
5✔
54
            Resource\Cookie::DEFAULT_LIFETIME,
5✔
55
        );
5✔
56
    }
57

58
    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
5✔
59
    {
60
        $io = new Console\Style\SymfonyStyle($input, $output);
5✔
61

62
        $lifetime = $input->getOption('lifetime');
5✔
63
        if (is_numeric($lifetime)) {
5✔
64
            $lifetime = (int) $lifetime;
4✔
65
        } else {
66
            $lifetime = Resource\Cookie::DEFAULT_LIFETIME;
1✔
67
        }
68

69
        $clearedCookies = Resource\Cookie::removeAll($lifetime);
5✔
70
        $count = count($clearedCookies);
5✔
71

72
        if ($io->isVerbose() && $count > 0) {
5✔
73
            $io->writeln('The following cookie files have been removed:');
1✔
74
            $io->listing(array_map(self::decorateFile(...), $clearedCookies));
1✔
75
        }
76

77
        $io->success(sprintf('Cleared %d cookie%s.', $count, 1 !== $count ? 's' : ''));
5✔
78

79
        return self::SUCCESS;
5✔
80
    }
81

82
    private static function decorateFile(Resource\File $file): string
1✔
83
    {
84
        return $file->getPathname();
1✔
85
    }
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc