Documentation

StreamFilter

A Trait to ease PHP Stream Filters manipulation with a SplFileObject

Tags
since
6.0.0

Table of Contents

$stream_filter_mode  : int
Stream filtering mode to apply on all filters
$stream_filters  : array<string|int, mixed>
collection of stream filters
$stream_regex  : string
PHP Stream Filter Regex
$stream_uri  : string
the real path
appendStreamFilter()  : $this
append a stream filter
clearStreamFilter()  : $this
Remove all registered stream filter
getStreamFilterMode()  : int
stream filter mode getter
hasStreamFilter()  : bool
Detect if the stream filter is already present
isActiveStreamFilter()  : bool
Tells whether the stream filter capabilities can be used
prependStreamFilter()  : $this
prepend a stream filter
removeStreamFilter()  : $this
Remove a filter from the collection
setStreamFilterMode()  : $this
stream filter mode Setter
validateString()  : mixed
assertStreamable()  : mixed
Check if the trait methods can be used
fetchStreamModeAsInt()  : int
Get the stream mode
getStreamFilterPath()  : string
Return the filter path
getStreamFilterPrefix()  : string
Return PHP stream filter prefix
initStreamFilter()  : mixed
Internal path setter
sanitizeStreamFilter()  : string
Sanitize the stream filter name

Properties

$stream_filter_mode

Stream filtering mode to apply on all filters

protected int $stream_filter_mode = STREAM_FILTER_ALL

$stream_filters

collection of stream filters

protected array<string|int, mixed> $stream_filters = []

$stream_regex

PHP Stream Filter Regex

protected string $stream_regex = ',^ php://filter/ (?P<mode>:?read=|write=)? # The resource open mode (?P<filters>.*?) # The resource registered filters /resource=(?P<resource>.*) # The resource path $,ix'

$stream_uri

the real path

protected string $stream_uri

the real path to the file

Methods

appendStreamFilter()

append a stream filter

public appendStreamFilter(string $filter_name) : $this
Parameters
$filter_name : string

a string or an object that implements the '__toString' method

Return values
$this

clearStreamFilter()

Remove all registered stream filter

public clearStreamFilter() : $this
Return values
$this

getStreamFilterMode()

stream filter mode getter

public getStreamFilterMode() : int
Return values
int

hasStreamFilter()

Detect if the stream filter is already present

public hasStreamFilter(string $filter_name) : bool
Parameters
$filter_name : string
Return values
bool

isActiveStreamFilter()

Tells whether the stream filter capabilities can be used

public isActiveStreamFilter() : bool
Return values
bool

prependStreamFilter()

prepend a stream filter

public prependStreamFilter(string $filter_name) : $this
Parameters
$filter_name : string

a string or an object that implements the '__toString' method

Return values
$this

removeStreamFilter()

Remove a filter from the collection

public removeStreamFilter(string $filter_name) : $this
Parameters
$filter_name : string
Return values
$this

setStreamFilterMode()

stream filter mode Setter

public setStreamFilterMode(int $mode) : $this

Set the new Stream Filter mode and remove all previously attached stream filters

Parameters
$mode : int
Tags
throws
OutOfBoundsException

If the mode is invalid

Return values
$this

validateString()

public abstract validateString(mixed $str) : mixed
Parameters
$str : mixed
Tags
inheritdoc
Return values
mixed

assertStreamable()

Check if the trait methods can be used

protected assertStreamable() : mixed
Tags
throws
LogicException

If the API can not be use

Return values
mixed

fetchStreamModeAsInt()

Get the stream mode

protected fetchStreamModeAsInt(string $mode) : int
Parameters
$mode : string
Return values
int

getStreamFilterPath()

Return the filter path

protected getStreamFilterPath() : string
Return values
string

getStreamFilterPrefix()

Return PHP stream filter prefix

protected getStreamFilterPrefix() : string
Return values
string

initStreamFilter()

Internal path setter

protected initStreamFilter(StreamIterator|SplFileObject|string $path) : mixed

The path must be an SplFileInfo object an object that implements the __toString method a path to a file

Parameters
$path : StreamIterator|SplFileObject|string

The file path

Return values
mixed

sanitizeStreamFilter()

Sanitize the stream filter name

protected sanitizeStreamFilter(string $filter_name) : string
Parameters
$filter_name : string

the stream filter name

Return values
string

Search results