public static function validateInput($caller, $input)
{
if (null !== $input) {
if (is_resource($input)) {
return $input;
}
if (is_scalar($input)) {
return (string) $input;
}
throw new \InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
}
return $input;
}
/** * 设置输入 * @param mixed $input * @return self */ public function setInput($input) { if ($this->isRunning()) { throw new \LogicException('Input can not be set while the process is running.'); } $this->input = Utils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $input); return $this; }