WordPress\AiClientDependencies\Nyholm\Psr7\Factory

Psr17Factory::createStreamFromFilepublicWP 1.0

Method of the class: Psr17Factory{}

No Hooks.

Returns

null. Nothing (null).

Usage

$Psr17Factory = new Psr17Factory();
$Psr17Factory->createStreamFromFile( $filename, $mode ): StreamInterface;
$filename(string) (required)
.
$mode(string)
.
Default: 'r'

Psr17Factory::createStreamFromFile() code WP 7.0

public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
    if ('' === $filename) {
        throw new \RuntimeException('Path cannot be empty');
    }
    if (\false === $resource = @\fopen($filename, $mode)) {
        if ('' === $mode || \false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], \true)) {
            throw new \InvalidArgumentException(\sprintf('The mode "%s" is invalid.', $mode));
        }
        throw new \RuntimeException(\sprintf('The file "%s" cannot be opened: %s', $filename, \error_get_last()['message'] ?? ''));
    }
    return Stream::create($resource);
}