OpcacheConfigurationCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 44
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

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