Completed
Push — master ( 5ea837...9dec3c )
by Paul
9s
created

ModuleDebugCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 13 1
A execute() 0 14 2
1
<?php
2
/**
3
 * This file is part of the PPI Framework.
4
 *
5
 * @copyright  Copyright (c) 2011-2016 Paul Dragoonis <[email protected]>
6
 * @license    http://opensource.org/licenses/mit-license.php MIT
7
 *
8
 * @link       http://www.ppi.io
9
 */
10
11
namespace PPI\Framework\Console\Command;
12
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
/**
17
 * ModuleDebug Command.
18
 *
19
 * @author      Vítor Brandão <[email protected]>
20
 */
21
class ModuleDebugCommand extends AbstractCommand
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function configure()
27
    {
28
        $this
29
            ->setName('module:list')
30
            ->setDescription('Displays information about the currently loaded modules')
31
            ->setHelp(<<<EOF
32
The <info>%command.name%</info> command dumps information about the currently loaded modules.
33
34
  <info>php %command.full_name%</info>
35
36
EOF
37
            );
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $appName = 'PPI';
46
        $mm      = $this->getServiceManager()->get('ModuleManager');
47
        $modules = $mm->getLoadedModules(true);
48
49
        $output->writeln(sprintf('%s is running with <info>%d</info> modules loaded.', $appName, count($modules)));
50
51
        foreach ($modules as $module) {
52
            $output->writeln(PHP_EOL . '<info>' . $module->getName() . '</info>');
53
            $output->writeln(' - <comment>namespace:</comment> ' . $module->getNamespace());
54
            $output->writeln(' - <comment>path:</comment>      ' . $module->getPath());
55
        }
56
    }
57
}
58