Passed
Push — master ( 92d243...5a69a1 )
by Eric
12:07
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 51
rs 10
c 0
b 0
f 0
ccs 10
cts 10
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureIO() 0 5 1
A __construct() 0 3 1
A getDefaultInputDefinition() 0 7 1
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 Symfony\Component\Console\Application as BaseApplication;
19
use Symfony\Component\Console\Input\InputDefinition;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Input\InputOption;
22
use Symfony\Component\Console\Output\OutputInterface;
23
24
use function getenv;
25
26
/**
27
 * @internal
28
 */
29
final class Application extends BaseApplication
30
{
31
    /**
32
     * Constants used in the Console Application for library information.
33
     */
34
    public const APPLICATION_DESCRIPTION = 'Reads the clover xml report from PHPUnit and calculates the coverage score.';
35
36
    public const APPLICATION_NAME = 'PHPUnit Coverage Check';
37
38
    public const COMMAND_NAME = 'coverage:check';
39
40
    public const VERSION = '2.0.0';
41
42
    /**
43
     * Override constructor.
44
     */
45 15
    public function __construct()
46
    {
47 15
        parent::__construct(self::APPLICATION_NAME, self::VERSION);
48
    }
49
50
    /**
51
     * Same as {@see self::getDefaultInputDefinition()}, but overriding configureIO().
52
     *
53
     * @see \Symfony\Component\Console\Application::configureIO()
54
     *
55
     * @inheritDoc
56
     */
57 12
    #[\Override]
58
    protected function configureIO(InputInterface $input, OutputInterface $output): void
59
    {
60 12
        $output->setDecorated(!(bool) getenv('PHPUNIT_TEST'));
61 12
        $input->setInteractive(false);
62
    }
63
64
    /**
65
     * Override's getDefaultInputDefinition() to clean up the output of the --help option.
66
     * By default, (without this override) it shows Symfony specific information along with
67
     * our command's information, much of which is not needed.
68
     *
69
     * @see \Symfony\Component\Console\Application::getDefaultInputDefinition()
70
     *
71
     * @inheritDoc
72
     */
73 15
    #[\Override]
74
    protected function getDefaultInputDefinition(): InputDefinition
75
    {
76 15
        return new InputDefinition(
77 15
            [
78 15
                new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
79 15
                new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this library version'),
80 15
            ]
81 15
        );
82
    }
83
}
84