Passed
Branch master (baa65a)
by Oliver
09:35
created

InputHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleInput() 0 16 3
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
     * @param InputInterface $input
17
     * @return ConfigurationHolder
18
     */
19
    public static function handleInput(InputInterface $input)
20
    {
21
        $configOption = $input->getOption('configuration');
22
        $configFile = ConfigLocator::locate($configOption);
23
        $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

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