Protobuf\Stream::wrap PHP Метод

wrap() публичный статический Метод

Wrap the input resource in a stream object.
public static wrap ( Stream | resource | string $resource = '', integer $size = null ) : Stream
$resource Stream | resource | string
$size integer
Результат Stream
    public static function wrap($resource = '', $size = null)
    {
        if ($resource instanceof Stream) {
            return $resource;
        }
        $type = gettype($resource);
        if ($type == 'string') {
            return self::fromString($resource, $size);
        }
        if ($type == 'resource') {
            return new self($resource, $size);
        }
        throw new InvalidArgumentException('Invalid resource type: ' . $type);
    }

Usage Example

 /**
  * Set 'encrypted_signature' value
  *
  * @param \Protobuf\Stream $value
  */
 public function setEncryptedSignature($value = null)
 {
     if ($value !== null && !$value instanceof \Protobuf\Stream) {
         $value = \Protobuf\Stream::wrap($value);
     }
     $this->encrypted_signature = $value;
 }
All Usage Examples Of Protobuf\Stream::wrap