InputHandler::handleInput()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 9
nc 4
nop 1
dl 0
loc 16
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
namespace OckCyp\CoversValidator\Handler;
4
5
use OckCyp\CoversValidator\Loader\ConfigLoader;
6
use OckCyp\CoversValidator\Loader\FileLoader;
7
use OckCyp\CoversValidator\Locator\ConfigLocator;
8
use OckCyp\CoversValidator\Model\ConfigurationHolder;
9
use Symfony\Component\Console\Input\InputInterface;
10
11
class InputHandler
12
{
13
    /**
14
     * Handle console input
15
     *
16
     * @return ConfigurationHolder
17
     */
18
    public static function handleInput(InputInterface $input)
19
    {
20
        $configOption = $input->getOption('configuration');
21
        $configFile = ConfigLocator::locate($configOption);
22
        $configurationHolder = ConfigLoader::loadConfig($configFile);
0 ignored issues
show
Bug introduced by
It seems like $configFile can also be of type null; however, parameter $fileName of OckCyp\CoversValidator\L...figLoader::loadConfig() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
        $configurationHolder = ConfigLoader::loadConfig(/** @scrutinizer ignore-type */ $configFile);
Loading history...
23
24
        $bootstrap = $configurationHolder->getBootstrap();
25
        if (null !== $input->getOption('bootstrap')) {
26
            $bootstrap = $input->getOption('bootstrap');
27
        }
28
29
        if ($bootstrap) {
30
            FileLoader::loadFile($bootstrap);
31
        }
32
33
        return $configurationHolder;
34
    }
35
}
36