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);
}