public function BooleanStrategy::hydrate in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/zendframework/zend-hydrator/src/Strategy/BooleanStrategy.php \Zend\Hydrator\Strategy\BooleanStrategy::hydrate()
Converts the given value so that it can be hydrated by the hydrator.
Parameters
int|string $value The original value.:
Return value
bool Returns the value that should be hydrated.
Throws
Overrides StrategyInterface::hydrate
File
- vendor/
zendframework/ zend-hydrator/ src/ Strategy/ BooleanStrategy.php, line 80
Class
- BooleanStrategy
- This Strategy extracts and hydrates int and string values to Boolean values
Namespace
Zend\Hydrator\StrategyCode
public function hydrate($value) {
if (!is_string($value) && !is_int($value)) {
throw new InvalidArgumentException(sprintf('Unable to hydrate. Expected string or int. %s was given.', is_object($value) ? get_class($value) : gettype($value)));
}
if ($value === $this->trueValue) {
return true;
}
if ($value === $this->falseValue) {
return false;
}
throw new InvalidArgumentException(sprintf('Unexpected value %s can\'t be hydrated. Expect %s or %s as Value.', $value, $this->trueValue, $this->falseValue));
}