Completed
Pull Request — master (#424)
by Anton
04:19
created

Config::initInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 1
rs 9.6666
c 0
b 0
f 0
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