PathLoggedForResourceCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 8 1
A execute() 0 12 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