Completed
Push — master ( 7a08de...9ce2ea )
by Daniel
04:39
created

Loader::__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;
9
10
use GravityMedia\Commander\Config;
11
12
/**
13
 * Config loader class.
14
 *
15
 * @package GravityMedia\Commander\Config
16
 */
17
class Loader
18
{
19
    /**
20
     * The config serializer.
21
     *
22
     * @var Serializer
23
     */
24
    protected $configSerializer;
25
26
    /**
27
     * Create config loader object.
28
     *
29
     * @param Serializer $configSerializer
30
     */
31
    public function __construct(Serializer $configSerializer)
32
    {
33
        $this->configSerializer = $configSerializer;
34
    }
35
36
    /**
37
     * Load config.
38
     *
39
     * @param string $filename
40
     *
41
     * @return Config
42
     */
43
    public function load($filename)
44
    {
45
        $data = file_get_contents($filename);
46
47
        return $this->configSerializer->deserialize($data, Config::class, 'json');
48
    }
49
}
50