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

codeigniter4 / CodeIgniter4 / 8677009716

13 Apr 2024 11:45PM UTC coverage: 84.44% (-2.2%) from 86.607%
8677009716

push

github

web-flow
Merge pull request #8776 from kenjis/fix-findQualifiedNameFromPath-Cannot-declare-class-v3

fix: Cannot declare class CodeIgniter\Config\Services, because the name is already in use

0 of 3 new or added lines in 1 file covered. (0.0%)

478 existing lines in 72 files now uncovered.

20318 of 24062 relevant lines covered (84.44%)

188.23 hits per line

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

81.82
/system/Commands/Cache/ClearCache.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Commands\Cache;
15

16
use CodeIgniter\Cache\CacheFactory;
17
use CodeIgniter\CLI\BaseCommand;
18
use CodeIgniter\CLI\CLI;
19
use Config\Cache;
20

21
/**
22
 * Clears current cache.
23
 */
24
class ClearCache extends BaseCommand
25
{
26
    /**
27
     * Command grouping.
28
     *
29
     * @var string
30
     */
31
    protected $group = 'Cache';
32

33
    /**
34
     * The Command's name
35
     *
36
     * @var string
37
     */
38
    protected $name = 'cache:clear';
39

40
    /**
41
     * the Command's short description
42
     *
43
     * @var string
44
     */
45
    protected $description = 'Clears the current system caches.';
46

47
    /**
48
     * the Command's usage
49
     *
50
     * @var string
51
     */
52
    protected $usage = 'cache:clear [<driver>]';
53

54
    /**
55
     * the Command's Arguments
56
     *
57
     * @var array<string, string>
58
     */
59
    protected $arguments = [
60
        'driver' => 'The cache driver to use',
61
    ];
62

63
    /**
64
     * Clears the cache
65
     */
66
    public function run(array $params)
67
    {
68
        $config  = config(Cache::class);
6✔
69
        $handler = $params[0] ?? $config->handler;
6✔
70

71
        if (! array_key_exists($handler, $config->validHandlers)) {
6✔
72
            CLI::error($handler . ' is not a valid cache handler.');
1✔
73

74
            return;
1✔
75
        }
76

77
        $config->handler = $handler;
5✔
78
        $cache           = CacheFactory::getHandler($config);
5✔
79

80
        if (! $cache->clean()) {
5✔
81
            // @codeCoverageIgnoreStart
UNCOV
82
            CLI::error('Error while clearing the cache.');
×
83

UNCOV
84
            return;
×
85
            // @codeCoverageIgnoreEnd
86
        }
87

88
        CLI::write(CLI::color('Cache cleared.', 'green'));
5✔
89
    }
90
}
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

© 2026 Coveralls, Inc