Completed
Push — develop ( 095a7f...8813d8 )
by Tom
03:54
created

ListCommand::execute()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 8.9197
c 0
b 0
f 0
cc 4
eloc 14
nc 4
nop 2
1
<?php
2
3
namespace N98\Magento\Command\Cache;
4
5
use N98\Util\Console\Helper\Table\Renderer\RendererFactory;
6
use N98\Util\Console\Helper\TableHelper;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class ListCommand extends AbstractCacheCommand
12
{
13 View Code Duplication
    protected function configure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
    {
15
        $this
16
            ->setName('cache:list')
17
            ->setDescription('Lists all magento caches')
18
            ->addOption(
19
                'format',
20
                null,
21
                InputOption::VALUE_OPTIONAL,
22
                'Output Format. One of [' . implode(',', RendererFactory::getFormats()) . ']'
23
            )
24
        ;
25
    }
26
27
    /**
28
     * @param InputInterface $input
29
     * @param OutputInterface $output
30
     * @return int|void
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $this->detectMagento($output, true);
35
        if (!$this->initMagento()) {
36
            return;
37
        }
38
39
        $cacheTypes = $this->_getCacheModel()->getTypes();
40
        $table = array();
41
        foreach ($cacheTypes as $cacheCode => $cacheInfo) {
42
            $table[] = array(
43
                $cacheCode,
44
                $cacheInfo['status'] ? 'enabled' : 'disabled',
45
            );
46
        }
47
48
        /* @var $tableHelper TableHelper */
49
        $tableHelper = $this->getHelper('table');
50
        $tableHelper
51
            ->setHeaders(array('code', 'status'))
52
            ->renderByFormat($output, $table, $input->getOption('format'));
53
    }
54
}
55