Lines Matching refs:resource
303 public static function streamFor($resource = '', array $options = []) argument
305 if (is_scalar($resource)) {
307 if ($resource !== '') {
308 fwrite($stream, $resource);
314 switch (gettype($resource)) {
320 $metaData = \stream_get_meta_data($resource);
323 fwrite($stream, stream_get_contents($resource));
325 $resource = $stream;
327 return new Stream($resource, $options);
329 if ($resource instanceof StreamInterface) {
330 return $resource;
331 } elseif ($resource instanceof \Iterator) {
332 return new PumpStream(function () use ($resource) {
333 if (!$resource->valid()) {
336 $result = $resource->current();
337 $resource->next();
340 } elseif (method_exists($resource, '__toString')) {
341 return Utils::streamFor((string) $resource, $options);
348 if (is_callable($resource)) {
349 return new PumpStream($resource, $options);
352 throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource));