LookupCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of Bowerphp.
5
 *
6
 * (c) Mauro D'Alatri <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bowerphp\Command;
13
14
use Bowerphp\Util\PackageNameVersionExtractor;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Lookup
21
 */
22
class LookupCommand extends Command
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    protected function configure()
28
    {
29
        $this
30
            ->setName('lookup')
31
            ->setDescription('Look up a package URL by name')
32
            ->addArgument('package', InputArgument::REQUIRED, 'Choose a package.')
33
            ->setHelp(<<<'EOT'
34
The <info>%command.name%</info> command is used for search with exact match the repository URL package
35
36
  <info>php %command.full_name% packageName</info>
37
EOT
38
            );
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46
        $this->setGithubToken($output);
47
48
        $name = $input->getArgument('package');
49
50
        $packageNameVersion = PackageNameVersionExtractor::fromString($name);
51
52
        $bowerphp = $this->getBowerphp($output);
53
54
        $package = $bowerphp->lookupPackage($packageNameVersion->name);
55
56
        $this->consoleOutput->writelnSearchOrLookup($package['name'], $package['url']);
57
    }
58
}
59