Completed
Push — master ( 83bd2d...9517e2 )
by Arne
03:10
created

AbstractCommand::readConfigurationFile()   B

Complexity

Conditions 6
Paths 13

Size

Total Lines 31
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 8.439
c 0
b 0
f 0
cc 6
eloc 13
nc 13
nop 1
1
<?php
2
3
namespace Archivr\Cli\Command;
4
5
use Archivr\Configuration;
6
use Archivr\ConfigurationFileReader;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
10
abstract class AbstractCommand extends Command
11
{
12
    protected function getConfiguration(InputInterface $input): Configuration
13
    {
14
        $reader = new ConfigurationFileReader();
15
16
        if ($input->getOption('config'))
17
        {
18
            return $reader->getConfiguration($input->getOption('config'));
19
        }
20
21
        if (is_file('archivr.json'))
22
        {
23
            return $reader->getConfiguration('archivr.json');
24
        }
25
26
        return null;
27
    }
28
}
29