1<?php 2 3namespace FINDOLOGIC\Export\Helpers; 4 5class EmptyValueNotAllowedException extends \RuntimeException 6{ 7 public function __construct($message = 'Empty values are not allowed!') 8 { 9 parent::__construct($message); 10 } 11} 12 13/** 14 * Class DataHelper 15 * @package FINDOLOGIC\Export\Helpers 16 * 17 * Collection of helper methods for data elements. 18 */ 19class DataHelper 20{ 21 /** 22 * Checks if the provided value is empty. 23 * 24 * @param string|int|float $value The value to check. Regardless of type, it is coerced into a string. 25 * @throws EmptyValueNotAllowedException If the value is empty. 26 * @return string Returns the value if not empty. 27 */ 28 public static function checkForEmptyValue($value) 29 { 30 $value = trim($value); 31 32 if ($value === '') { 33 throw new EmptyValueNotAllowedException(); 34 } 35 36 return $value; 37 } 38} 39