Completed
Pull Request — master (#38)
by Boris
04:23 queued 02:11
created

OpcacheConfigurationCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 28.57%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 4
dl 0
loc 44
ccs 6
cts 21
cp 0.2857
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\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 4
    protected function configure()
24
    {
25 4
        $this
26 4
            ->setName('opcache:configuration')
27 4
            ->setDescription('Get configuration information about the cache')
28 4
            ->setHelp('');
29 4
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $this->ensureExtensionLoaded('Zend OPcache');
37
38
        $info = $this->getCacheTool()->opcache_get_configuration();
39
40
        $output->writeln("<info>{$info['version']['opcache_product_name']}</info> <comment>{$info['version']['version']}</comment>");
41
42
        $table = new Table($output);
43
        $table
44
            ->setHeaders(array('Directive', 'Value'))
45
            ->setRows($this->processDirectives($info['directives']))
46
        ;
47
48
        $table->render($output);
0 ignored issues
show
Unused Code introduced by
The call to Table::render() has too many arguments starting with $output.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
49
    }
50
51
    protected function processDirectives(array $directives)
52
    {
53
        $list = array();
54
55
        foreach ($directives as $name => $value) {
56
            $list[] = array($name, var_export($value, true));
57
        }
58
59
        return $list;
60
    }
61
}
62