Info   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 57
ccs 0
cts 9
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 25 3
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\Cli\Commands\Cache;
13
14
use BlitzPHP\Cli\Console\Command;
15
16
/**
17
 * Affiche des informations sur le cache.
18
 */
19
class Info extends Command
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected $group = 'Cache';
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    protected $name = 'cache:info';
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    protected $description = 'Affiche les informations du cache de fichiers dans le système actuel.';
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    protected $service = 'Service de mise en cache';
40
41
    /**
42
     * {@inheritDoc}
43
     */
44
    protected $arguments = [
45
        'driver' => 'Le pilote de cache à utiliser',
46
    ];
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function execute(array $params)
52
    {
53
        $config = config('cache');
54
        helper('number');
55
56
        if ($config['handler'] !== 'file') {
57
            $this->fail('Cette commande ne prend en charge que le gestionnaire de cache de fichiers.');
58
59
            return;
60
        }
61
62
        $cache  = service('cache', $config);
63
        $caches = $cache->info();
64
        $tbody  = [];
65
66
        foreach ($caches as $key => $field) {
67
            $tbody[] = [
68
                'nom'               => $key,
69
                'chemin du serveur' => clean_path($field['server_path']),
70
                'taille'            => number_to_size($field['size']),
0 ignored issues
show
Bug introduced by
The function number_to_size was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
                'taille'            => /** @scrutinizer ignore-call */ number_to_size($field['size']),
Loading history...
71
                'date'              => $field['date'],                      // @todo formatter avec Utilities\Date
72
            ];
73
        }
74
75
        $this->table($tbody, ['head' => 'boldGreen']);
76
    }
77
}
78