<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Helpers;


use ModulesGarden\Servers\ZimbraEmail\App\Enums\ProductParams;
use ModulesGarden\Servers\ZimbraEmail\App\Enums\Size;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 18.09.19
 * Time: 09:22
 * Class AccountHelper
 */
class AccountHelper
{

    /**
     * @description return formatted data per API data
     * @param $date
     * @return false|string|null
     */
    public static function getFormattedData($date, $format = 'd/m/Y')
    {
        if(!$date)
        {
            return null;
        }
        $tmpDate = strstr($date, '.', true);
        $tmpDate = $tmpDate ? $tmpDate : $date;

        return date($format, strtotime($tmpDate));
    }

    /**
     * @param $quote
     * @return float|int|string
     */
    public static function getQuotaAsMb($quote)
    {
        return isset($quote) ? ($quote / Size::B_TO_MB)  : ProductParams::SIZE_UNLIMITED;
    }

}