Completed
Push — 1.x ( 2f995a...fa8c59 )
by Samuel
18:04
created

OpcacheConfigurationCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 16 1
A processDirectives() 0 10 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 Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class OpcacheConfigurationCommand extends AbstractCommand
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    protected function configure()
23
    {
24
        $this
25
            ->setName('opcache:configuration')
26
            ->setDescription('Get configuration information about the cache')
27
            ->setHelp('');
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $this->ensureExtensionLoaded('Zend OPcache');
36
37
        $info = $this->getCacheTool()->opcache_get_configuration();
38
39
        $output->writeln("<info>{$info['version']['opcache_product_name']}</info> <comment>{$info['version']['version']}</comment>");
40
41
        $table = $this->getHelper('table');
42
        $table
43
            ->setHeaders(array('Directive', 'Value'))
44
            ->setRows($this->processDirectives($info['directives']))
45
        ;
46
47
        $table->render($output);
48
    }
49
50
    protected function processDirectives(array $directives)
51
    {
52
        $list = array();
53
54
        foreach ($directives as $name => $value) {
55
            $list[] = array($name, var_export($value, true));
56
        }
57
58
        return $list;
59
    }
60
}
61