DebugTemplateCacheCommand::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 3
eloc 5
nc 3
nop 2
1
<?php
2
/**
3
 * @author Shota Hoshino <[email protected]>
4
 */
5
6
namespace Hshn\AngularBundle\Command;
7
8
9
use Hshn\AngularBundle\TemplateCache\TemplateCacheManager;
10
use Hshn\AngularBundle\TemplateCache\TemplateFinder;
11
use Symfony\Component\Console\Command\Command;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
class DebugTemplateCacheCommand extends Command
16
{
17
    /**
18
     * @var TemplateCacheManager
19
     */
20
    private $manager;
21
22
    /**
23
     * @var TemplateFinder
24
     */
25
    private $finder;
26
27
    /**
28
     * @param TemplateCacheManager $manager
29
     * @param TemplateFinder $finder
30
     */
31
    public function __construct(TemplateCacheManager $manager, TemplateFinder $finder)
32
    {
33
        parent::__construct();
34
35
        $this->manager = $manager;
36
        $this->finder = $finder;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function configure()
43
    {
44
        $this
45
            ->setName('hshn:angular:template-cache:debug')
46
            ->setDescription('Displays configured template caches')
47
        ;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function execute(InputInterface $input, OutputInterface $output)
54
    {
55
        foreach ($this->manager->getModules() as $name => $module) {
56
            $output->writeln(sprintf('<comment>%s</comment>', $module->getName()));
57
            foreach ($this->finder->find($module) as $template) {
58
                $output->writeln(sprintf('  %s (%s)', $template->getRelativePathname(), $template->getPathname()));
59
            }
60
        }
61
    }
62
}
63