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

LookupCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 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