LogsCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 7 1
A execute() 0 6 2
1
<?php
2
3
namespace Dock\Cli;
4
5
use Dock\Docker\Containers\Logs;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class LogsCommand extends Command
12
{
13
    /**
14
     * @var Logs
15
     */
16
    private $logs;
17
18
    /**
19
     * @param Logs $logs
20
     */
21
    public function __construct(Logs $logs)
22
    {
23
        parent::__construct();
24
25
        $this->logs = $logs;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function configure()
32
    {
33
        $this
34
            ->setName('logs')
35
            ->setDescription('Follow logs of application containers')
36
            ->addArgument('component', InputArgument::OPTIONAL, 'Name of component to follow');
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        $input->getArgument('component')
45
            ? $this->logs->displayComponent($input->getArgument('component'))
46
            : $this->logs->displayAll();
47
    }
48
}
49