You are here

trait EmptyGuardTrait in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-stdlib/src/Guard/EmptyGuardTrait.php \Zend\Stdlib\Guard\EmptyGuardTrait

Provide a guard method against empty data

Hierarchy

File

vendor/zendframework/zend-stdlib/src/Guard/EmptyGuardTrait.php, line 15

Namespace

Zend\Stdlib\Guard
View source
trait EmptyGuardTrait {

  /**
   * Verify that the data is not empty
   *
   * @param  mixed  $data           the data to verify
   * @param  string $dataName       the data name
   * @param  string $exceptionClass FQCN for the exception
   * @throws \Exception
   */
  protected function guardAgainstEmpty($data, $dataName = 'Argument', $exceptionClass = 'Zend\\Stdlib\\Exception\\InvalidArgumentException') {
    if (empty($data)) {
      $message = sprintf('%s cannot be empty', $dataName);
      throw new $exceptionClass($message);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EmptyGuardTrait::guardAgainstEmpty protected function Verify that the data is not empty