<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace ModulesGarden\HostingQuotaNotifications\App\Helper\Basics;

use ModulesGarden\HostingQuotaNotifications\App\Helper\Lang\Lang;
use ModulesGarden\HostingQuotaNotifications\App\Libs\Groups\Constants as GroupConstant;

/**
 * Description of Converter
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class Converter
{
    public static function domainStatus($status)
    {
        switch ($status)
        {
            case 'terminate':
                return 'Terminated';
            case 'suspend':
                return 'Suspended';
        }
        return $status;
    }

    public static function kind($kind)
    {
        switch ($kind)
        {
            case 'disk':
            case 'bw':
                return Lang::getAbsoulteLang('kind', $kind);
        }
        return $kind;
    }

    public static function overType($overType)
    {
        switch ($overType)
        {
            case GroupConstant::PERCENTAGE:
                return '%';
        }
        return GroupConstant::MB;
    }

    public static function valueToPercent($value, $limit)
    {

        return $value / $limit * 100;
    }

    public static function toTypeAndValue($params)
    {
        unset($params['customLimit']);
        unset($params['hid']);
        foreach($params as $key => $value)
        {
            return [
                'usage' => (int) $value,
                'usageUnit' => $key,
            ];
        }
    }



}
