ShowCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 42
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 0 13 2
1
<?php
2
3
namespace SyncFS\Command;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * Class ShowCommand
11
 *
12
 * @package SyncFS\Command
13
 * @author  Matej Velikonja <[email protected]>
14
 */
15
class ShowCommand extends Command
16
{
17
    const COMMAND_NAME = 'show';
18
19
    /**
20
     * Configure command.
21
     */
22 5
    protected function configure()
23
    {
24 5
        $this
25 5
            ->setName(self::COMMAND_NAME)
26 5
            ->setDescription("Show configuration.")
27 5
            ->addArgument(
28 5
                self::ARG_CONFIG_PATH,
29 5
                InputArgument::OPTIONAL,
30 5
                'Path to config file.',
31 5
                $this->getDefaultConfiguration()
32 5
            );
33 5
    }
34
35
    /**
36
     * @param InputInterface  $input
37
     * @param OutputInterface $output
38
     *
39
     * @throws \RuntimeException
40
     *
41
     * @return int|null|void
42
     */
43 3
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45 3
        $file = $input->getArgument(self::ARG_CONFIG_PATH);
46
47 3
        if (! is_readable($file)) {
48 1
            throw new \RuntimeException(sprintf('<error>File `%s` cannot be read!</error>', $file));
49
        }
50
51 2
        $content = file_get_contents($file);
52
53 2
        $output->writeln(sprintf('<info>Configuration located in `%s`.</info>', $file));
54 2
        $output->writeln($content);
55 2
    }
56
}
57