Issues (224)

src/Console/Command/ConfigOption.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Console\Command;
16
17
use Fidry\Console\IO;
0 ignored issues
show
The type Fidry\Console\IO was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use KevinGH\Box\Configuration\Configuration;
19
use KevinGH\Box\Console\ConfigurationLoader;
20
use KevinGH\Box\Json\JsonValidationException;
21
use KevinGH\Box\NotInstantiable;
22
use Symfony\Component\Console\Input\InputOption;
23
24
/**
25
 * Allows a configuration file path to be specified for a command.
26
 *
27
 * @private
28
 */
29
final class ConfigOption
30
{
31
    use NotInstantiable;
32
33
    private const CONFIG_PARAM = 'config';
34
35
    public static function getOptionInput(): InputOption
36
    {
37
        return new InputOption(
38
            self::CONFIG_PARAM,
39
            'c',
40
            InputOption::VALUE_REQUIRED,
41
            'The alternative configuration file path.',
42
        );
43
    }
44
45
    /**
46
     * Returns the configuration settings.
47
     *
48
     * @param bool $allowNoFile Load the config nonetheless if not file is found when true
49
     *
50
     * @throws JsonValidationException
51
     */
52
    public static function getConfig(IO $io, bool $allowNoFile = false): Configuration
53
    {
54
        return ConfigurationLoader::getConfig(
55
            $io->getInput()->getOption(self::CONFIG_PARAM),
56
            $io,
57
            $allowNoFile,
58
        );
59
    }
60
}
61