StatRealpathGetCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 21.74%

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 52
ccs 5
cts 23
cp 0.2174
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A processFileList() 0 15 2
A execute() 0 19 1
A configure() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of CacheTool.
5
 *
6
 * (c) Samuel Gordalina <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CacheTool\Command;
13
14
use CacheTool\Util\Formatter;
15
use Symfony\Component\Console\Helper\Table;
16
use Symfony\Component\Console\Helper\TableSeparator;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class StatRealpathGetCommand extends AbstractCommand
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 25
    protected function configure()
26
    {
27
        $this
28 25
            ->setName('stat:realpath_get')
29 25
            ->setDescription('Show summary information of realpath cache entries')
30 25
            ->setHelp('');
31 25
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output): int
37
    {
38
        $info = $this->getCacheTool()->stat_realpath_get();
39
40
        $table = new Table($output);
41
        $table
42
            ->setHeaders([
43
                'Path entry',
44
                'key',
45
                'is_dir',
46
                'realpath',
47
                'expires',
48
            ])
49
            ->setRows($this->processFilelist($info))
50
        ;
51
52
        $table->render();
53
54
        return 0;
55
    }
56
57
    protected function processFileList(array $cacheList)
58
    {
59
        $list = [];
60
61
        foreach ($cacheList as $path_entry => $item) {
62
            $list[] = [
63
               $path_entry,
64
               $item['key'],
65
               $item['is_dir'],
66
               $item['realpath'],
67
               $item['expires'],
68
            ];
69
        }
70
71
        return $list;
72
    }
73
}
74