ConfigTrait::config()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
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
    public function config(): AbstractConfig
25
    {
26
        if (!isset($this->__config__)) {
27
            $this->__config__ = ClassConfig::createInstance(get_class($this), $this);
28
        }
29
        return $this->__config__;
30
    }
31
}