DumpTemplateCacheCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace Hshn\AngularBundle\Command;
4
5
use Hshn\AngularBundle\TemplateCache\Dumper;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * @author Shota Hoshino <[email protected]>
13
 */
14
class DumpTemplateCacheCommand extends Command
15
{
16
    /**
17
     * @var \Hshn\AngularBundle\TemplateCache\Dumper
18
     */
19
    private $dumper;
20
21
    /**
22
     * @var string
23
     */
24
    private $target;
25
26
    /**
27
     * @param Dumper $dumper
28
     * @param string $target
29
     */
30
    public function __construct(Dumper $dumper, $target)
31
    {
32
        parent::__construct();
33
34
        $this->dumper = $dumper;
35
        $this->target = $target;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function configure()
42
    {
43
        $this
44
            ->setName('hshn:angular:template-cache:dump')
45
            ->setDescription('Dumps template cache to the filesystem')
46
            ->addOption('target', null, InputOption::VALUE_OPTIONAL, 'Override the target path to dump')
47
        ;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function execute(InputInterface $input, OutputInterface $output)
54
    {
55
        $target = $input->getOption('target') ?: $this->target;
56
57
        $output->writeln('<info>[file+]</info> ' . $target);
58
59
        $this->dumper->dump($target);
60
    }
61
}
62