WordPress\AiClientDependencies\Nyholm\Psr7
Stream::create
Creates a new PSR-7 stream.
Method of the class: Stream{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = Stream::create( $body ): StreamInterface;
- $body(string|resource|StreamInterface)
- .
Default:''
Stream::create() Stream::create code WP 7.0
public static function create($body = ''): StreamInterface
{
if ($body instanceof StreamInterface) {
return $body;
}
if (\is_string($body)) {
if (200000 <= \strlen($body)) {
$body = self::openZvalStream($body);
} else {
$resource = \fopen('php://memory', 'r+');
\fwrite($resource, $body);
\fseek($resource, 0);
$body = $resource;
}
}
if (!\is_resource($body)) {
throw new \InvalidArgumentException('First argument to Stream::create() must be a string, resource or StreamInterface');
}
return new self($body);
}