Completed
Push — master ( 53e74a...4c1ea9 )
by Robbie
01:57
created

ConfigurationLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 9 3
1
<?php
2
3
namespace SilverLeague\Console\Framework\Loader;
4
5
use RuntimeException;
6
use SilverLeague\Console\Framework\ConsoleBase;
7
use Symfony\Component\Yaml\Yaml;
8
9
/**
10
 * The Configuration Loader is reponsible for loading the core configuration YAML file, and merging in any
11
 * other configuration files from other locations
12
 *
13
 * @package silverstripe-console
14
 * @author  Robbie Averill <[email protected]>
15
 */
16
class ConfigurationLoader extends ConsoleBase
17
{
18
    /**
19
     * The configuration file name to look for
20
     *
21
     * @var string
22
     */
23
    const CONFIGURATION_FILE = 'console.yml';
24
25
    /**
26
     * Load the YAML configuration for the application and return it
27
     *
28
     * @return array
29
     * @throws RuntimeException If the filecould not be loaded
30
     */
31
    public function load()
32
    {
33
        $filename = CONSOLE_BASE_DIR . '/' . self::CONFIGURATION_FILE;
34
        if (!file_exists($filename) || !is_readable($filename)) {
35
            throw new RuntimeException('The configuration YAML file does not exist!');
36
        }
37
38
        return Yaml::parse($filename);
39
    }
40
}
41