argumentValue = $argumentValue; $this->destinationTypeDescription = $destinationTypeDescription; $type = gettype($argumentValue); switch ($type) { case 'boolean': $shownName = $argumentValue ? 'TRUE' : 'FALSE'; break; case 'integer': case 'double': $shownName = (string) $argumentValue; break; case 'string': $shownName = "'{$argumentValue}'"; break; case 'object': $shownName = get_class($argumentValue); break; default: $shownName = $type; break; } $message = "Can't convert {$shownName} to a {$destinationTypeDescription}"; parent::__construct($message, \Punic\Exception::BAD_ARGUMENT_TYPE, $previous); } /** * Retrieves the value of the invalid argument. */ public function getArgumentValue() { return $this->argumentValue; } /** * Retrieves the destination type (or a list of destination types). * * @return string|array */ public function getDestinationTypeDescription() { return $this->destinationTypeDescription; } }