Completed
Push — master ( 480535...7e0bd3 )
by Anton
12s
created

Config   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A initInstance() 0 9 1
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Proxy;
12
13
use Bluz\Application\Application;
14
use Bluz\Config\Config as Instance;
15
16
/**
17
 * Proxy to Config
18
 *
19
 * Example of usage
20
 * <code>
21
 *     use Bluz\Proxy\Config;
22
 *
23
 *     if (!Config::getData('db')) {
24
 *          throw new Exception('Configuration for `db` is missed');
25
 *     }
26
 * </code>
27
 *
28
 * @package  Bluz\Proxy
29
 * @author   Anton Shevchuk
30
 *
31
 * @method   static Instance getInstance()
32
 *
33
 * @method   static mixed getData($key = null, $section = null)
34
 * @see      Instance::getData()
35
 *
36
 * @method   static mixed getModuleData($module, $section = null)
37
 * @see      Instance::getModuleData()
38
 */
39
final class Config
40
{
41
    use ProxyTrait;
42
43
    /**
44
     * Init instance
45
     *
46
     * @return Instance
47
     * @throws \Bluz\Config\ConfigException
48
     */
49 1
    protected static function initInstance()
50
    {
51 1
        $instance = new Instance();
52 1
        $instance->setPath(Application::getInstance()->getPath());
53 1
        $instance->setEnvironment(Application::getInstance()->getEnvironment());
54 1
        $instance->init();
55
56 1
        return $instance;
57
    }
58
}
59