FlushCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 15 3
A configure() 0 7 1
1
<?php
2
3
namespace N98\Magento\Command\Cache;
4
5
use N98\Magento\Application;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class FlushCommand extends AbstractModifierCommand
10
{
11
    protected function configure()
12
    {
13
        $this
14
            ->setName('cache:flush')
15
            ->setDescription('Flush magento cache storage')
16
        ;
17
    }
18
19
    /**
20
     * @param \Symfony\Component\Console\Input\InputInterface $input
21
     * @param \Symfony\Component\Console\Output\OutputInterface $output
22
     * @return int|void
23
     */
24
    protected function execute(InputInterface $input, OutputInterface $output)
25
    {
26
        $this->detectMagento($output, true);
27
        if (!$this->initMagento()) {
28
            return;
29
        }
30
31
        $cacheManager = $this->getCacheManager();
32
33
        $availableTypes = $cacheManager->getAvailableTypes();
34
        foreach ($availableTypes as $cacheType) {
35
            $cacheManager->flush(array($cacheType));
36
            $output->writeln('<info><comment>' . $cacheType . '</comment> cache flushed</info>');
37
        }
38
    }
39
}
40