Completed
Pull Request — master (#3)
by nicolas
03:49
created

PathLoggedForResourceCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
3
namespace Dekalee\Cdn77Bundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class PathLoggedForResourceCommand
13
 */
14
class PathLoggedForResourceCommand extends ContainerAwareCommand
15
{
16
    /**
17
     * Configure the command
18
     */
19
    protected function configure()
20
    {
21
        $this
22
            ->setName('dekalee:cdn77:path-logged-for-resource')
23
            ->setDescription('Get all the path stored in the log for a resource')
24
            ->addOption('resource', null, InputOption::VALUE_REQUIRED, 'The resource to get the log from')
25
        ;
26
    }
27
28
    /**
29
     * @param InputInterface  $input
30
     * @param OutputInterface $output
31
     *
32
     * @return int|null|void
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $ressource = $input->getOption('resource');
37
38
        $logs = $this->getContainer()->get('dekalee_cdn77.query.resource_log')->execute($ressource);
39
40
        $output->writeln('List of file in the log');
41
42
        foreach ($logs as $log) {
43
            $output->writeln($log['path']);
44
        }
45
    }
46
}
47