Completed
Push — master ( 38df09...7a08de )
by Daniel
08:33
created

CommanderConfigLoader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of the Commander project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Commander\Config\Loader;
9
10
use GravityMedia\Commander\Config\CommanderConfig;
11
use GravityMedia\Commander\Serializer\ConfigSerializer;
12
13
/**
14
 * Commander config loader class.
15
 *
16
 * @package GravityMedia\Commander\Loader
17
 */
18
class CommanderConfigLoader
19
{
20
    /**
21
     * The config serializer.
22
     *
23
     * @var ConfigSerializer
24
     */
25
    protected $configSerializer;
26
27
    /**
28
     * Create commander config loader.
29
     *
30
     * @param ConfigSerializer $configSerializer
31
     */
32
    public function __construct(ConfigSerializer $configSerializer)
33
    {
34
        $this->configSerializer = $configSerializer;
35
    }
36
37
    /**
38
     * Load commander config.
39
     *
40
     * @param string $filename
41
     *
42
     * @return CommanderConfig
43
     */
44
    public function load($filename)
45
    {
46
        return $this->configSerializer->deserialize(
47
            file_get_contents($filename),
48
            CommanderConfig::class,
49
            'json'
50
        );
51
    }
52
}
53