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

Loader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 33
ccs 0
cts 6
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 6 1
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