|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This file is part of PHPUnit Coverage Check. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Eric Sizemore <[email protected]> |
|
9
|
|
|
* (c) Richard Regeer <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* This source file is subject to the MIT license. For the full copyright, |
|
12
|
|
|
* license information, and credits/acknowledgements, please view the LICENSE |
|
13
|
|
|
* and README files that were distributed with this source code. |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Esi\CoverageCheck; |
|
17
|
|
|
|
|
18
|
|
|
use Override; |
|
19
|
|
|
use Symfony\Component\Console\Application as BaseApplication; |
|
20
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
|
21
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
22
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
23
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
24
|
|
|
|
|
25
|
|
|
use function getenv; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @internal |
|
29
|
|
|
*/ |
|
30
|
|
|
final class Application extends BaseApplication |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* Constants used in the Console Application for library information. |
|
34
|
|
|
*/ |
|
35
|
|
|
public const string APPLICATION_DESCRIPTION = 'Reads the clover xml report from PHPUnit and calculates the coverage score.'; |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
public const string APPLICATION_NAME = 'PHPUnit Coverage Check'; |
|
38
|
|
|
|
|
39
|
|
|
public const string COMMAND_NAME = 'coverage:check'; |
|
40
|
|
|
|
|
41
|
|
|
public const string VERSION = '3.0.0'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Override constructor. |
|
45
|
|
|
*/ |
|
46
|
15 |
|
public function __construct() |
|
47
|
|
|
{ |
|
48
|
15 |
|
parent::__construct(self::APPLICATION_NAME, self::VERSION); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Same as {@see self::getDefaultInputDefinition()}, but overriding configureIO(). |
|
53
|
|
|
* |
|
54
|
|
|
* @see BaseApplication::configureIO() |
|
55
|
|
|
* |
|
56
|
|
|
* @inheritDoc |
|
57
|
|
|
*/ |
|
58
|
12 |
|
#[Override] |
|
59
|
|
|
protected function configureIO(InputInterface $input, OutputInterface $output): void |
|
60
|
|
|
{ |
|
61
|
12 |
|
$output->setDecorated(!(bool) getenv('PHPUNIT_TEST')); |
|
62
|
12 |
|
$input->setInteractive(false); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Override's getDefaultInputDefinition() to clean up the output of the --help option. |
|
67
|
|
|
* By default, (without this override) it shows Symfony specific information along with |
|
68
|
|
|
* our command's information, much of which is not needed. |
|
69
|
|
|
* |
|
70
|
|
|
* @see BaseApplication::getDefaultInputDefinition() |
|
71
|
|
|
* |
|
72
|
|
|
* @inheritDoc |
|
73
|
|
|
*/ |
|
74
|
15 |
|
#[Override] |
|
75
|
|
|
protected function getDefaultInputDefinition(): InputDefinition |
|
76
|
|
|
{ |
|
77
|
15 |
|
return new InputDefinition( |
|
78
|
15 |
|
[ |
|
79
|
15 |
|
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'), |
|
80
|
15 |
|
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this library version'), |
|
81
|
15 |
|
] |
|
82
|
15 |
|
); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|