class Stream implements StreamInterface (View source)

PSR-7 StreamInterface implementation

Largely "inspired" by laminas-diactoros implementation.

Constants

DATA_INPUT_RAW

DATA_INPUT_URLENCODED

DATA_INPUT_BASE64

Methods

static StreamInterface
createFromData(string $data, string $dataEncoding = self::DATA_INPUT_RAW, string $mode = 'rb', string|MediaTypeInterface $mediaType = 'text/plain')

Create a Stream from binary data

static StreamInterface
createFromFile(string $filename, string $mode = 'r')

No description

__construct(resource $stream)

No description

getMetadata($key = null)

No description

isSeekable()

No description

read($length)

No description

tell()

No description

isWritable()

No description

seek($offset, $whence = SEEK_SET)

No description

__toString()

No description

getSize()

No description

rewind()

No description

detach()

No description

getContents()

No description

close()

No description

eof()

No description

write($string)

No description

isReadable()

No description

static 
isValidResource($resource)

No description

Details

static StreamInterface createFromData(string $data, string $dataEncoding = self::DATA_INPUT_RAW, string $mode = 'rb', string|MediaTypeInterface $mediaType = 'text/plain')

Create a Stream from binary data

Parameters

string $data
string $dataEncoding Describe how $data is encoded
string $mode
string|MediaTypeInterface $mediaType

Return Value

StreamInterface

static StreamInterface createFromFile(string $filename, string $mode = 'r')

Parameters

string $filename Filename
string $mode File open mode

Return Value

StreamInterface

__construct(resource $stream)

Parameters

resource $stream

getMetadata($key = null)

Parameters

$key

isSeekable()

read($length)

Parameters

$length

tell()

isWritable()

seek($offset, $whence = SEEK_SET)

Parameters

$offset
$whence

__toString()

getSize()

rewind()

detach()

getContents()

close()

eof()

write($string)

Parameters

$string

isReadable()

static protected isValidResource($resource)

Parameters

$resource