Completed
Push — master ( b2d8c9...799a4d )
by Tony
01:32
created

ConfigTrait::config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace ClassConfig\Traits;
4
5
use ClassConfig\AbstractConfig;
6
use ClassConfig\ClassConfig;
7
8
/**
9
 * Trait ConfigTrait
10
 * @package ClassConfig\Traits
11
 */
12
trait ConfigTrait
13
{
14
    /**
15
     * @var AbstractConfig
16
     */
17
    protected $__config__;
18
19
    /**
20
     * @return AbstractConfig
21
     * @throws \Doctrine\Common\Annotations\AnnotationException
22
     * @throws \ReflectionException
23
     */
24
    protected function config(): AbstractConfig
25
    {
26
        if (!isset($this->__config__)) {
27
            $this->__config__ = ClassConfig::createInstance(get_class($this));
28
        }
29
        return $this->__config__;
30
    }
31
}