ListCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Bowerphp.
5
 *
6
 * (c) Massimiliano Arione <[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\Installer\Installer;
15
use Bowerphp\Util\ZipArchive;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Symfony\Component\Finder\Finder;
19
20
/**
21
 * This command shows a list of installed packages.
22
 * Not to be confused with original "list" command of Symfony, that has been
23
 * renamed to "list-commands" (see CommandListCommand.php)
24
 */
25
class ListCommand extends Command
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function configure()
31
    {
32
        $this
33
            ->setName('list')
34
            ->setDescription('Lists installed packages')
35
            ->setHelp(<<<'EOT'
36
The <info>%command.name%</info> lists installed packages.
37
38
  <info>%command.full_name%</info>
39
EOT
40
            )
41
        ;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $this->setGithubToken($output);
50
51
        $installer = new Installer($this->filesystem, new ZipArchive(), $this->config);
52
        $bowerphp = $this->getBowerphp($output);
53
        $packages = $bowerphp->getInstalledPackages($installer, new Finder());
54
55
        foreach ($packages as $package) {
56
            $this->consoleOutput->writelnListPackage($package, $bowerphp);
57
        }
58
    }
59
}
60