Passed
Pull Request — master (#69)
by Dave
02:21
created

BaseLineFileHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaselineFile() 0 3 1
A configureBaseLineFileArgument() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Command\internal;
6
7
use DaveLiddament\StaticAnalysisResultsBaseliner\Domain\Common\BaseLineFileName;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
13
class BaseLineFileHelper
14
{
15
    private const BASELINE_FILE = 'baseline-file';
16
17
    public static function configureBaseLineFileArgument(Command $command): void
18
    {
19
        $command->addArgument(
20
            self::BASELINE_FILE,
21
            InputArgument::REQUIRED, 'Baseline file'
22
        );
23
        $command->addOption(
24
            self::BASELINE_FILE,
25
            null,
26
            InputOption::VALUE_REQUIRED,
27
            'Path to the root of the project you are creating baseline for'
28
        );
29
    }
30
31
    /**
32
     * @throws InvalidConfigException
33
     */
34
    public static function getBaselineFile(InputInterface $input): BaseLineFileName
35
    {
36
        return new BaseLineFileName(CliConfigReader::getArgument($input, self::BASELINE_FILE));
37
    }
38
}
39