PathLoggedForResourceCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Dekalee\Cdn77Bundle\Command;
4
5
use Dekalee\Cdn77\Query\ResourceLogQuery;
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
 * Class PathLoggedForResourceCommand
13
 */
14
class PathLoggedForResourceCommand extends Command
15
{
16
    protected $resourceLogQuery;
17
18
    /**
19
     * @param ResourceLogQuery $resourceLogQuery
20
     */
21
    public function __construct(ResourceLogQuery $resourceLogQuery)
22
    {
23
        parent::__construct();
24
        $this->resourceLogQuery = $resourceLogQuery;
25
    }
26
27
28
    /**
29
     * Configure the command
30
     */
31
    protected function configure()
32
    {
33
        $this
34
            ->setName('dekalee:cdn77:path-logged-for-resource')
35
            ->setDescription('Get all the path stored in the log for a resource')
36
            ->addOption('resource', null, InputOption::VALUE_REQUIRED, 'The resource to get the log from')
37
        ;
38
    }
39
40
    /**
41
     * @param InputInterface  $input
42
     * @param OutputInterface $output
43
     *
44
     * @return int|null|void
45
     */
46
    protected function execute(InputInterface $input, OutputInterface $output)
47
    {
48
        $ressource = $input->getOption('resource');
49
50
        $logs = $this->resourceLogQuery->execute($ressource);
51
52
        $output->writeln('List of file in the log');
53
54
        foreach ($logs as $log) {
55
            $output->writeln($log['path']);
56
        }
57
    }
58
}
59