class FilecontentFilterIterator extends MultiplePcreFilterIterator

FilecontentFilterIterator filters files by their contents using patterns (regexps or strings).

Properties

protected $matchRegexps from MultiplePcreFilterIterator
protected $noMatchRegexps from MultiplePcreFilterIterator

Methods

rewind()

This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after rewind in some cases.

__construct(Iterator $iterator, array $matchPatterns, array $noMatchPatterns)

No description

bool
isAccepted(string $string)

Checks whether the string is accepted by the regex filters.

bool
isRegex(string $str)

Checks whether the string is a regex.

string
toRegex(string $str)

Converts string to regexp if necessary.

bool
accept()

Filters the iterator values.

Details

in FilterIterator at line 32
rewind()

This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after rewind in some cases.

__construct(Iterator $iterator, array $matchPatterns, array $noMatchPatterns)

Parameters

Iterator $iterator The Iterator to filter
array $matchPatterns An array of patterns that need to match
array $noMatchPatterns An array of patterns that need to not match

protected bool isAccepted(string $string)

Checks whether the string is accepted by the regex filters.

If there is no regexps defined in the class, this method will accept the string. Such case can be handled by child classes before calling the method if they want to apply a different behavior.

Parameters

string $string The string to be matched against filters

Return Value

bool

protected bool isRegex(string $str)

Checks whether the string is a regex.

Parameters

string $str

Return Value

bool Whether the given string is a regex

at line 54
protected string toRegex(string $str)

Converts string to regexp if necessary.

Parameters

string $str Pattern

Return Value

string regexp corresponding to a given string

at line 27
bool accept()

Filters the iterator values.

Return Value

bool true if the value should be kept, false otherwise