ConfigCacheCleanUpCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A initialize() 0 6 1
A execute() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015-2016 Yahoo Japan Corporation
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 YahooJapan\ConfigCacheBundle\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * ConfigCacheCleanUpCommand is a command to clear the cache in the temporary directory and the Symfony cache directory.
20
 */
21
class ConfigCacheCleanUpCommand extends ContainerAwareCommand
22
{
23
    protected $cleanup;
24
    protected $filesystem;
25
    protected $cacheDirectory;
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 8
    protected function configure()
31
    {
32 8
        $this
33 8
            ->setName('config-cache:cleanup')
34 8
            ->setDescription('Cleans up the cache')
35
            ;
36 8
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 1
    protected function initialize(InputInterface $input, OutputInterface $output)
42
    {
43 1
        $this->cleanup        = $this->getContainer()->get('yahoo_japan_config_cache.cache_cleanup');
44 1
        $this->filesystem     = $this->getContainer()->get('filesystem');
45 1
        $this->cacheDirectory = $this->getContainer()->getParameter('kernel.cache_dir');
46 1
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    protected function execute(InputInterface $input, OutputInterface $output)
52
    {
53
        // remove temporary directory
54 1
        $this->cleanup->cleanUp();
55
        // also remove Symfony cache directory created by running AppKernel::boot()
56 1
        $this->filesystem->remove($this->cacheDirectory);
57
58 1
        $output->writeln("Cleaned up the cache");
59 1
    }
60
}
61