You are here

public function ExplodeStrategy::hydrate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-hydrator/src/Strategy/ExplodeStrategy.php \Zend\Hydrator\Strategy\ExplodeStrategy::hydrate()

Split a string by delimiter

Parameters

string|null $value:

Return value

string[]

Throws

Exception\InvalidArgumentException

Overrides StrategyInterface::hydrate

File

vendor/zendframework/zend-hydrator/src/Strategy/ExplodeStrategy.php, line 71

Class

ExplodeStrategy

Namespace

Zend\Hydrator\Strategy

Code

public function hydrate($value) {
  if (null === $value) {
    return [];
  }
  if (!(is_string($value) || is_numeric($value))) {
    throw new Exception\InvalidArgumentException(sprintf('%s expects argument 1 to be string, %s provided instead', __METHOD__, is_object($value) ? get_class($value) : gettype($value)));
  }
  if ($this->explodeLimit !== null) {
    return explode($this->valueDelimiter, $value, $this->explodeLimit);
  }
  return explode($this->valueDelimiter, $value);
}