You are here

public function BooleanStrategy::__construct in Zircon Profile 8.0

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

Parameters

int|string $trueValue:

int|string $falseValue:

Throws

InvalidArgumentException

File

vendor/zendframework/zend-hydrator/src/Strategy/BooleanStrategy.php, line 34

Class

BooleanStrategy
This Strategy extracts and hydrates int and string values to Boolean values

Namespace

Zend\Hydrator\Strategy

Code

public function __construct($trueValue, $falseValue) {
  if (!is_int($trueValue) && !is_string($trueValue)) {
    throw new InvalidArgumentException(sprintf('Unable to instantiate BooleanStrategy. Expected int or string as $trueValue. %s was given', is_object($trueValue) ? get_class($trueValue) : gettype($trueValue)));
  }
  if (!is_int($falseValue) && !is_string($falseValue)) {
    throw new InvalidArgumentException(sprintf('Unable to instantiate BooleanStrategy. Expected int or string as $falseValue. %s was given', is_object($falseValue) ? get_class($falseValue) : gettype($falseValue)));
  }
  $this->trueValue = $trueValue;
  $this->falseValue = $falseValue;
}