think\process\Utils::validateInput PHP Method

validateInput() public static method

验证并进行规范化Process输入。
public static validateInput ( string $caller, mixed $input ) : string
$caller string
$input mixed
return string
    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;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 设置输入
  * @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;
 }
All Usage Examples Of think\process\Utils::validateInput