Application::getHelp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the jade/jade package.
5
 *
6
 * (c) Slince <[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 Jade\Console;
13
14
use Jade\App;
15
use Jade\CommandProviderInterface;
16
use Symfony\Component\Console\Application as SymfonyApplication;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class Application extends SymfonyApplication
21
{
22
    /**
23
     * Logo Text
24
     *
25
     * @var string
26
     */
27
    const LOGO = <<<EOT
28
 ____  _          ___
29
/ ___|| |__   ___|_ _|_ __
30
\___ \| '_ \ / _ \| || '_ \
31
 ___) | | | |  __/| || | | |
32
|____/|_| |_|\___|___|_| |_|
33
34
EOT;
35
36
    /**
37
     * @var App
38
     */
39
    protected $decorated;
40
41
    public function __construct(App $app)
42
    {
43
        $this->decorated = $app;
44
        parent::__construct('Jade', '0.0.1');
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getHelp()
51
    {
52
        return parent::getHelp() . PHP_EOL . static::LOGO;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function doRun(InputInterface $input, OutputInterface $output)
59
    {
60
        $this->decorated->boot();
61
62
        $this->registerCommands();
63
64
        return parent::doRun($input, $output);
65
    }
66
67
    protected function registerCommands()
68
    {
69
        foreach ($this->decorated->getProviders() as $provider) {
70
            if ($provider instanceof CommandProviderInterface) {
71
                $provider->provide($this, $this->decorated->getContainer());
72
            }
73
        }
74
    }
75
}