Menu

## Stream
in package
implements StreamInterface

Stream.php : 22

PSR-7 compliant data stream class.

Represents a stream of data as defined by the PSR-7 StreamInterface.

##### Tags

see
  https://www.kotchasan.com/

### Interfaces, Classes and Traits

StreamInterface
  Describes a data stream.

### Table of Contents

$meta : array<string|int, mixed>
  Stream metadata.
$readable : bool
  Flag indicating if the stream is readable.
$seekable : bool
  Flag indicating if the stream is seekable.
$size : null|int
  Stream size.
$stream : resource
  Stream resource.
$writable : bool
  Flag indicating if the stream is writable.
__construct() : mixed
  Creates a new Stream instance.
__toString() : string
  Gets the contents of the stream as a string.
close() : void
  Closes the stream and releases its resources.
detach() : resource|null
  Detaches the stream resource and returns it.
eof() : bool
  Checks if the end of the stream has been reached.
getContents() : string
  Gets the contents of the stream as a string.
getMetadata() : array<string|int, mixed>|mixed|null
  Gets the metadata of the stream or a specific key of the metadata.
getSize() : int|null
  Gets the size of the stream in bytes.
isReadable() : bool
  Checks if the stream is readable.
isSeekable() : bool
  Checks if the stream is seekable.
isWritable() : bool
  Checks if the stream is writable.
read() : string
  Reads data from the stream.
rewind() : mixed
  Seeks to a specific position in the stream.
seek() : mixed
  เลื่อน pointer ไปยังตำแหน่งที่กำหนด
tell() : int
  คืนค่าตำแหน่งของ pointer ปัจจุบัน
write() : int
  เขียนข้อมูลลงบน stream คืนค่าจำนวน byte ที่เขียน

### Properties

#### $meta

Stream.php : 29

Stream metadata.

`protected array<string|int, mixed> $meta`

#### $readable

Stream.php : 36

Flag indicating if the stream is readable.

`protected bool $readable`

#### $seekable

Stream.php : 43

Flag indicating if the stream is seekable.

`protected bool $seekable`

#### $size

Stream.php : 50

Stream size.

`protected null|int $size`

#### $stream

Stream.php : 57

Stream resource.

`protected resource $stream`

#### $writable

Stream.php : 64

Flag indicating if the stream is writable.

`protected bool $writable`

### Methods

#### __construct()

Stream.php : 74

Creates a new Stream instance.

`public __construct(resource|string $stream[, string $mode = 'r' ]) : mixed`

##### Parameters

$stream : resource|string

  The stream resource or a string representing a file path or URL.

$mode : string = 'r'

  The mode in which to open the stream.

##### Tags

throws
  InvalidArgumentException

  If the stream is not a valid resource.

##### Return values

mixed —

#### __toString()

Stream.php : 98

Gets the contents of the stream as a string.

`public __toString() : string`

##### Tags

throws
  RuntimeException

  If unable to read the stream contents.

##### Return values

string —

The stream contents.

#### close()

Stream.php : 116

Closes the stream and releases its resources.

`public close() : void`

##### Return values

void —

#### detach()

Stream.php : 131

Detaches the stream resource and returns it.

`public detach() : resource|null`

##### Return values

resource|null —

The detached stream resource.

#### eof()

Stream.php : 149

Checks if the end of the stream has been reached.

`public eof() : bool`

##### Return values

bool —

True if the end of the stream has been reached, false otherwise.

#### getContents()

Stream.php : 161

Gets the contents of the stream as a string.

`public getContents() : string`

##### Tags

throws
  RuntimeException

  If unable to read the stream contents.

##### Return values

string —

The stream contents.

#### getMetadata()

Stream.php : 179

Gets the metadata of the stream or a specific key of the metadata.

`public getMetadata([string|null $key = null ]) : array<string|int, mixed>|mixed|null`

##### Parameters

$key : string|null = null

  The metadata key to retrieve.

##### Return values

array<string|int, mixed>|mixed|null —

The metadata as an array, a specific metadata value, or null if the key is not found.

#### getSize()

Stream.php : 197

Gets the size of the stream in bytes.

`public getSize() : int|null`

##### Return values

int|null —

The size of the stream in bytes, or null if the size is unknown.

#### isReadable()

Stream.php : 216

Checks if the stream is readable.

`public isReadable() : bool`

##### Return values

bool —

True if the stream is readable, false otherwise.

#### isSeekable()

Stream.php : 231

Checks if the stream is seekable.

`public isSeekable() : bool`

##### Return values

bool —

True if the stream is seekable, false otherwise.

#### isWritable()

Stream.php : 245

Checks if the stream is writable.

`public isWritable() : bool`

##### Return values

bool —

True if the stream is writable, false otherwise.

#### read()

Stream.php : 264

Reads data from the stream.

`public read(int $length) : string`

##### Parameters

$length : int

  The number of bytes to read.

##### Tags

throws
  RuntimeException

  If unable to read the stream.

##### Return values

string —

The data read from the stream.

#### rewind()

Stream.php : 284

Seeks to a specific position in the stream.

`public rewind() : mixed`

##### Tags

throws
  RuntimeException

  on failure

##### Return values

mixed —

#### seek()

Stream.php : 297

เลื่อน pointer ไปยังตำแหน่งที่กำหนด

`public seek(int $offset[, int $whence = SEEK_SET ]) : mixed`

##### Parameters

$offset : int

  ตำแหน่งของ pointer

$whence : int = SEEK_SET

##### Tags

throws
  RuntimeException

  on failure

##### Return values

mixed —

#### tell()

Stream.php : 311

คืนค่าตำแหน่งของ pointer ปัจจุบัน

`public tell() : int`

##### Tags

throws
  RuntimeException

  on error

##### Return values

int —

#### write()

Stream.php : 330

เขียนข้อมูลลงบน stream คืนค่าจำนวน byte ที่เขียน

`public write(string $string) : int`

##### Parameters

$string : string

  ข้อมูลที่เขียน

##### Tags

throws
  RuntimeException

  on failure

##### Return values

int —

## Search results