Completed
Push — develop ( 1b34c6...481302 )
by Paul
02:47
created

Application::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Console;
4
5
use PhpUnitGen\Container\ConsoleContainerFactory;
6
use PhpUnitGen\Container\ContainerFactory;
7
use Symfony\Component\Console\Application as AbstractApplication;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class Application.
13
 *
14
 * @author     Paul Thébaud <[email protected]>.
15
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
16
 * @license    https://opensource.org/licenses/MIT The MIT license.
17
 * @link       https://github.com/paul-thebaud/phpunit-generator
18
 * @since      Class available since Release 2.0.0.
19
 */
20
class Application extends AbstractApplication
21
{
22
    /**
23
     * @var string VERSION The current application version.
24
     */
25
    const VERSION = '2.0.0';
26
27
    /**
28
     * Application constructor.
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct('phpunitgen', static::VERSION);
33
34
        $containerFactory = new ConsoleContainerFactory(new ContainerFactory());
35
36
        $this->add(new GenerateCommand($containerFactory));
37
        $this->add(new GenerateOneCommand($containerFactory));
38
        $this->add(new GenerateDefaultCommand($containerFactory));
39
        $this->add(new GenerateOneDefaultCommand($containerFactory));
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function doRun(InputInterface $input, OutputInterface $output)
46
    {
47
        if (! $output->isQuiet()) {
48
            $output->writeln(sprintf(
49
                "phpunitgen %s by Paul Thébaud.\n\n",
50
                $this->getVersion()
51
            ));
52
        }
53
54
        if ($input->hasParameterOption('--version') ||
55
            $input->hasParameterOption('-V')) {
56
            return 0;
57
        }
58
59
        parent::doRun($input, $output);
60
    }
61
}
62