GetCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 14 1
A execute() 0 9 1
1
<?php
2
3
namespace SilverLeague\Console\Command\Config;
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
 * Lookup configuration settings by class and property name
11
 *
12
 * @package silverstripe-console
13
 * @author  Robbie Averill <[email protected]>
14
 */
15
class GetCommand extends AbstractConfigCommand
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('config:get')
24
            ->setDescription('Look up a specific configuration value')
25
            ->addArgument('class', InputArgument::REQUIRED)
26
            ->addArgument('property', InputArgument::REQUIRED);
27
28
        $this->setHelp(<<<HELP
29
Look up a specific configuration value and output it directly. This command can be used for build processes,
30
automated scripts, quick checks etc where raw output is required outside of the SilverStripe application.
31
HELP
32
        );
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     * @param InputInterface $input
38
     * @param OutputInterface $output
39
     */
40
    protected function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        $result = $this->getConfig()->get(
43
            $input->getArgument('class'),
44
            $input->getArgument('property'),
45
            true
46
        );
47
        $output->writeln(var_export($result, true));
48
    }
49
}
50