<?php

namespace ThurData\Servers\KerioEmail\Core\Traits;

use function ThurData\Servers\KerioEmail\Core\Helper\di;

/**
 * Description of AppParams
 *
 * @autor ThurData <info@thurdata.ch>
 */
trait AppParams
{
    /** 
     *
     * @var type \ThurData\Servers\KerioEmail\Core\App\AppParamsContainer
     */
    protected $appParams = null;    
    
    public function initParams()
    {
        if ($this->appParams === null)
        {
            $this->appParams = di('appParamsContainer');
        }
    }
    
    public function setAppParam($key = null, $value = null)
    {   
        $this->initParams();
        
        $this->appParams->setParam($key, $value);
    }
    
    public function getAppParams()
    {
        $this->initParams();
        
        return $this->appParams->getParams();
    }
    
    public function getAppParam($key, $default = null)
    {
        $this->initParams();
        
        return $this->appParams->getParam($key, $default);
    }    
}
