<?php
/**
 * Class ModuleConfigurationHandler
 * User: ThurData
 * Date: 2019-11-19
 * Time: 08:21
 * @package ThurData\Servers\KerioEmail\App\Traits
 */

namespace ThurData\Servers\KerioEmail\App\Traits;


use ThurData\Servers\KerioEmail\Core\Configuration\Data;

trait ModuleConfigurationHandler
{
    /**
     *
     * @var Data
     */
    protected $moduleData;

    /**
     *
     * @return Data
     */
    public function getModuleData()
    {
        return $this->moduleData;
    }

    /**
     *
     * @param bool $reload
     * @return Data|null
     */
    public function loadModuleData($reload = false)
    {
        /**
         * unset data if need reload
         */
        if($reload)
        {
            $this->moduleData = null;
        }

        /**
         * load data
         */
        if(!$this->moduleData)
        {
            $this->moduleData = new Data();
        }

        /**
         * return data
         */
        return $this->moduleData;
    }

}