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

StatRealpathGetCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 52
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 18 1
A processFileList() 0 16 2
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