예제 #1
0
파일: XMLRPC.php 프로젝트: jasny/Q
 /**
  * Class constructor
  *
  * @param mixed $url      URL (string), stream (resource) or Q\Stream      
  * @param array $options  Additional options. Properties of this class, methods/callbacks of ssh2_connect() and auth ('none', 'password', 'publickey' or 'hostbased') + props for auth. 
  */
 public function __construct($url, $options = array())
 {
     if (is_array($url)) {
         $options = $url + $options;
         $url = isset($options['url']) ? $options['url'] : null;
     }
     if (is_object($url) || isset($options['use'])) {
         $this->connection = is_object($url) ? $url : (is_object($options['use']) ? $options['use'] : Stream::create($options['use'], $options));
         if (!interface_exists(__NAMESPACE__ . '::StreamingConnection', false) || !$this->connection instanceof StreamingConnection) {
             throw new Exception("You can't use an " . (is_object($this->connection) ? get_class($this->connection) : $this->connection) . " as a stream.");
         }
     } else {
         $this->connection = Connection::create($url, $options);
     }
     $this->copyfiles = !empty($options['copyfiles']);
     $this->keepalive = isset($this->stream) || !empty($options['keepalive']);
 }
예제 #2
0
파일: _stream.php 프로젝트: iddqdby/f7
/**
 * Create new Stream monad.
 *
 * @param mixed $value a value
 * @return Stream a Stream monad
 */
function stream($traversable) : Stream
{
    return Stream::create($traversable);
}