<?php

namespace ThurData\Servers\KerioEmail\Core\UI\Traits;

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

/**
 * WhmcsParams related functions
 *
 * @autor ThurData <info@thurdata.ch>
 */
trait WhmcsParams
{
    /**
     *
     * @var \ThurData\Servers\KerioEmail\Core\Helper\WhmcsParams
     */
    private $whmcsParams = null;

    public function initWhmcsParams()
    {
        if ($this->whmcsParams === null)
        {
            $this->whmcsParams = di('whmcsParams');
        }
    }

    protected function getWhmcsParamByKey($key, $default = false)
    {
        $this->initWhmcsParams();

        return $this->whmcsParams->getParamByKey($key, $default);
    }

    public function getWhmcsParamsByKeys(array $keys = [], $default = false)
    {
        $selectedParams = [];
        foreach ($keys as $key)
        {
            $selectedParams[$key] = $this->getWhmcsParamByKey($key, $default);
        }

        return $selectedParams;
    }
}
