function HttpFactory::createStreamFromFile
Overrides StreamFactoryInterface::createStreamFromFile
File
-
vendor/
guzzlehttp/ psr7/ src/ HttpFactory.php, line 47
Class
- HttpFactory
- Implements all of the PSR-17 interfaces.
Namespace
GuzzleHttp\Psr7Code
public function createStreamFromFile(string $file, string $mode = 'r') : StreamInterface {
try {
$resource = Utils::tryFopen($file, $mode);
} catch (\RuntimeException $e) {
if ('' === $mode || false === \in_array($mode[0], [
'r',
'w',
'a',
'x',
'c',
], true)) {
throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e);
}
throw $e;
}
return Utils::streamFor($resource);
}