Completed
Pull Request — 1.x (#35)
by
unknown
18:26
created

StatRealpathGetCommand::processFileList()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 16
rs 9.4285
nc 2
cc 2
eloc 10
nop 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\TableSeparator;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
class StatRealpathGetCommand extends AbstractCommand
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    protected function configure()
25
    {
26
        $this
27
            ->setName('stat:realpath_get')
28
            ->setDescription('Show summary information of realpath cache entries')
29
            ->setHelp('');
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $info = $this->getCacheTool()->stat_realpath_get();
38
39
        $table = $this->getHelper('table');
40
        $table
41
            ->setHeaders(array(
42
                'Path entry',
43
                'key',
44
                'is_dir',
45
                'realpath',
46
                'expires',
47
            ))
48
            ->setRows($this->processFilelist($info))
49
        ;
50
51
        $table->render($output);
52
    }
53
54
    protected function processFileList(array $cacheList)
55
    {
56
        $list = array();
57
58
        foreach ($cacheList as $path_entry => $item) {
59
            $list[] = array(
60
               $path_entry,
61
               $item['key'],
62
               $item['is_dir'],
63
               $item['realpath'],
64
               $item['expires'],
65
            );
66
        }
67
68
        return $list;
69
    }
70
}
71