Application   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A doRunParent() 0 3 1
A __construct() 0 10 1
A doRun() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of PhpUnitGen.
5
 *
6
 * (c) 2017-2018 Paul Thébaud <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpUnitGen\Console;
13
14
use PhpUnitGen\Container\ConsoleContainerFactory;
15
use PhpUnitGen\Container\ContainerFactory;
16
use Symfony\Component\Console\Application as AbstractApplication;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Component\Stopwatch\Stopwatch;
20
21
/**
22
 * Class Application.
23
 *
24
 * @author     Paul Thébaud <[email protected]>.
25
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
26
 * @license    https://opensource.org/licenses/MIT The MIT license.
27
 * @link       https://github.com/paul-thebaud/phpunit-generator
28
 * @since      Class available since Release 2.0.0.
29
 */
30
class Application extends AbstractApplication
31
{
32
    /**
33
     * @var string VERSION The current application version.
34
     */
35
    public const VERSION = '2.1.4';
36
37
    /**
38
     * Application constructor.
39
     */
40
    public function __construct()
41
    {
42
        parent::__construct('phpunitgen', static::VERSION);
43
44
        $containerFactory = new ConsoleContainerFactory(new ContainerFactory());
45
        $stopwatch        = new Stopwatch();
46
47
        $this->add(new GenerateCommand($containerFactory, $stopwatch));
48
49
        $this->setDefaultCommand('generate', true);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function doRun(InputInterface $input, OutputInterface $output): int
56
    {
57
        if (! $output->isQuiet()) {
58
            $output->writeln(sprintf(
59
                "PhpUnitGen by Paul Thébaud (version <info>%s</info>).\n",
60
                $this->getVersion()
61
            ));
62
        }
63
64
        return $this->doRunParent($input, $output);
65
    }
66
67
    /**
68
     * Run the "doRun" from parent.
69
     *
70
     * @param InputInterface  $input  An input interface.
71
     * @param OutputInterface $output An output interface.
72
     *
73
     * @return int 0 if everything went fine, or an error code.
74
     *
75
     * @throws \Throwable If there is an exception during application run.
76
     */
77
    protected function doRunParent(InputInterface $input, OutputInterface $output): int
78
    {
79
        return parent::doRun($input, $output);
80
    }
81
}
82