Completed
Push — master ( 9056d7...e52bc4 )
by Adam
08:23
created

Configuration::getConfiguration()   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
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Utility;
4
5
use BestServedCold\PhalueObjects\ExtendedArray\ExtendedArrayTrait;
6
use BestServedCold\PhalueObjects\File\Yaml;
7
use BestServedCold\PhalueObjects\Pattern\Singleton;
8
9
/**
10
 * Class Configuration
11
 *
12
 * Note: This class will work without extending the Singleton patter via the static
13
 * property. however, I've left it extended to make it clear that it is,
14
 * effectively, following the Singleton pattern.
15
 *
16
 * @package   BestServedCold\PhalueObjects\Utility
17
 * @author    Adam Lewis <[email protected]>
18
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
19
 * @license	  http://http://opensource.org/licenses/GPL-3.0 GPL License
20
 * @link	  http://bestservedcold.com
21
 * @since	  0.0.1-alpha
22
 * @version   0.0.2-alpha
23
 */
24
class Configuration extends Singleton
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
25
{
26
    use ExtendedArrayTrait;
27
28
    private static $configuration = [ ];
29
30
    /**
31
     * @var string
32
     */
33
    protected static $file = '/Configuration/configuration.yml';
34
35
    /**
36
     * @param  string $key
37
     * @return mixed
38
     */
39 1
    public static function get($key)
40
    {
41 1
        empty(self::$configuration) ? self::getConfiguration() : null;
42 1
        return self::getFromArrayUsingJsonNotation(self::$configuration, $key);
43
    }
44
45
    /**
46
     * Get Configuration
47
     *
48
     * @return array
49
     */
50
    public static function getConfiguration()
51
    {
52
        return self::$configuration = Yaml::fromString(__DIR__ . self::$file)->parse();
53
    }
54
}
55