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
|
|
|
use Symfony\Component\Stopwatch\Stopwatch; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Application. |
14
|
|
|
* |
15
|
|
|
* @author Paul Thébaud <[email protected]>. |
16
|
|
|
* @copyright 2017-2018 Paul Thébaud <[email protected]>. |
17
|
|
|
* @license https://opensource.org/licenses/MIT The MIT license. |
18
|
|
|
* @link https://github.com/paul-thebaud/phpunit-generator |
19
|
|
|
* @since Class available since Release 2.0.0. |
20
|
|
|
*/ |
21
|
|
|
class Application extends AbstractApplication |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string VERSION The current application version. |
25
|
|
|
*/ |
26
|
|
|
public const VERSION = '2.0.0'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Application constructor. |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
parent::__construct('phpunitgen', static::VERSION); |
34
|
|
|
|
35
|
|
|
$containerFactory = new ConsoleContainerFactory(new ContainerFactory()); |
36
|
|
|
$stopwatch = new Stopwatch(); |
37
|
|
|
|
38
|
|
|
$this->add(new GenerateCommand($containerFactory, $stopwatch)); |
39
|
|
|
$this->add(new GenerateOneCommand($containerFactory, $stopwatch)); |
40
|
|
|
$this->add(new GenerateDefaultCommand($containerFactory, $stopwatch)); |
41
|
|
|
$this->add(new GenerateOneDefaultCommand($containerFactory, $stopwatch)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function doRun(InputInterface $input, OutputInterface $output): int |
48
|
|
|
{ |
49
|
|
|
if (! $output->isQuiet()) { |
50
|
|
|
$output->writeln("PhpUnitGen by Paul Thébaud.\n"); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $this->doRunParent($input, $output); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Run the "doRun" from parent. |
58
|
|
|
* |
59
|
|
|
* @param InputInterface $input An input interface. |
60
|
|
|
* @param OutputInterface $output An output interface. |
61
|
|
|
* |
62
|
|
|
* @return int 0 if everything went fine, or an error code. |
63
|
|
|
* |
64
|
|
|
* @throws \Throwable If there is an exception during application run. |
65
|
|
|
*/ |
66
|
|
|
protected function doRunParent(InputInterface $input, OutputInterface $output): int |
67
|
|
|
{ |
68
|
|
|
return parent::doRun($input, $output); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|