Exemplo n.º 1
0
 public function __construct($resource)
 {
     if (!Valid::sshSftpResource($resource)) {
         throw new UnexpectedValueException('Parameter must be a valid stream resource');
     }
     $this->resource = $resource;
 }
Exemplo n.º 2
0
 public function __construct($host, $port_param = null)
 {
     $port = $port_param === null ? 22 : $port_param;
     if (!Valid::tcpPort($port)) {
         throw new UnexpectedValueException('port must be an integer between 0 and 65535');
     }
     $this->host = $host;
     $this->port = (int) $port;
 }
Exemplo n.º 3
0
 /**
  * Authenticate an SSH session resource.
  *
  * @internal
  *
  * @return bool
  *
  * @throws UnexpectedValueException if $resource is not a valid SSH2 session resource.
  */
 public function authenticateSessionResource($resource)
 {
     if (!Valid::sshSessionResource($resource)) {
         throw new UnexpectedValueException('Parameter must be a valid SSH2 Session resource');
     }
     $args = $this->params;
     array_unshift($args, $resource);
     return call_user_func_array($this->method, $args);
 }
Exemplo n.º 4
0
 /**
  * Construct an execution stream in blocking mode.
  *
  * @param resource $stream
  *
  * @throws UnexpectedValueException if $stream is not a valid stream
  */
 public function __construct($stream)
 {
     if (!Valid::streamResource($stream)) {
         throw new UnexpectedValueException('Parameter must be a valid stream resource');
     }
     $stderr = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
     if (!$stderr) {
         throw new UnexpectedValueException('Parameter is a valid stream, but does not contain an »stderr« substream');
     }
     $this->stdio = $stream;
     $this->stderr = $stderr;
 }