Lines Matching refs:resource
39 * @param resource|string|StreamInterface $resource Entity body data
43 * @throws \InvalidArgumentException if the $resource arg is not valid.
45 public static function factory($resource = '', array $options = [])
47 $type = gettype($resource);
51 if ($resource !== '') {
52 fwrite($stream, $resource);
58 if ($type == 'resource') {
59 return new self($resource, $options);
62 if ($resource instanceof StreamInterface) {
63 return $resource;
66 if ($type == 'object' && method_exists($resource, '__toString')) {
67 return self::factory((string) $resource, $options);
70 if (is_callable($resource)) {
71 return new PumpStream($resource, $options);
74 if ($resource instanceof \Iterator) {
75 return new PumpStream(function () use ($resource) {
76 if (!$resource->valid()) {
79 $result = $resource->current();
80 $resource->next();
85 throw new \InvalidArgumentException('Invalid resource type: ' . $type);
97 * @param resource $stream Stream resource to wrap.
100 * @throws \InvalidArgumentException if the stream is not a stream resource
105 throw new \InvalidArgumentException('Stream must be a resource');