1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
<?php

namespace ClassConfig\Traits;

use ClassConfig\AbstractConfig;
use ClassConfig\ClassConfig;

/**
 * Trait ConfigTrait
 * @package ClassConfig\Traits
 */
trait ConfigTrait
{
    /**
     * @var AbstractConfig
     */
    protected $__config__;

    /**
     * @return AbstractConfig
     * @throws \Doctrine\Common\Annotations\AnnotationException
     * @throws \ReflectionException
     */
    public function config(): AbstractConfig
    {
        if (!isset($this->__config__)) {
            $this->__config__ = ClassConfig::createInstance(get_class($this), $this);
        }
        return $this->__config__;
    }
}