You are here

trait NullGuardTrait in Zircon Profile 8.0

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

Provide a guard method against null data

Hierarchy

File

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

Namespace

Zend\Stdlib\Guard
View source
trait NullGuardTrait {

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

}

Members

Namesort descending Modifiers Type Description Overrides
NullGuardTrait::guardAgainstNull protected function Verify that the data is not null