AccountHelper.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Helpers;
  3. use ModulesGarden\Servers\ZimbraEmail\App\Enums\ProductParams;
  4. use ModulesGarden\Servers\ZimbraEmail\App\Enums\Size;
  5. /**
  6. *
  7. * Created by PhpStorm.
  8. * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
  9. * Date: 18.09.19
  10. * Time: 09:22
  11. * Class AccountHelper
  12. */
  13. class AccountHelper
  14. {
  15. /**
  16. * @description return formatted data per API data
  17. * @param $date
  18. * @return false|string|null
  19. */
  20. public static function getFormattedData($date, $format = 'd/m/Y')
  21. {
  22. if(!$date)
  23. {
  24. return null;
  25. }
  26. $tmpDate = strstr($date, '.', true);
  27. $tmpDate = $tmpDate ? $tmpDate : $date;
  28. return date($format, strtotime($tmpDate));
  29. }
  30. /**
  31. * @param $quote
  32. * @return float|int|string
  33. */
  34. public static function getQuotaAsMb($quote)
  35. {
  36. return isset($quote) ? ($quote / Size::B_TO_MB) : ProductParams::SIZE_UNLIMITED;
  37. }
  38. }