Completed
Push — master ( 8110dc...01b890 )
by Robbie
01:10
created

LookupCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 4
dl 0
loc 24
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 7 1
1
<?php
2
3
namespace SilverLeague\Console\Command\Object;
4
5
use SilverLeague\Console\Command\SilverStripeCommand;
6
use SilverStripe\Core\Injector\Injector;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Shows which Object is returned from the Injector
13
 *
14
 * @package silverstripe-console
15
 * @author  Robbie Averill <[email protected]>
16
 */
17
class LookupCommand extends SilverStripeCommand
18
{
19
    /**
20
     * {@inheritDoc}
21
     */
22 1
    protected function configure()
23
    {
24
        $this
25 1
            ->setName('object:lookup')
26 1
            ->setDescription('Shows which Object is returned from the Injector')
27 1
            ->addArgument('object', InputArgument::REQUIRED, 'The Object to look up');
28 1
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 1
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35 1
        $object = $input->getArgument('object');
36 1
        $resolvedTo = get_class(Injector::inst()->get($object));
37
38 1
        $output->writeln('<comment>' . $object . '</comment> resolves to <info>' . $resolvedTo . '</info>');
39 1
    }
40
}
41