LogsCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 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