class Finder implements IteratorAggregate

Finder allows searching through directory trees using iterator.

Finder::findFiles('*.php') ->size('> 10kB') ->from('.') ->exclude('temp');

Methods

static Finder
find(string|array $masks = ['*'])

Begins search for files and directories matching mask.

static Finder
findFiles(string|array $masks = ['*'])

Begins search for files matching mask.

static Finder
findDirectories(string|array $masks = ['*'])

Begins search for directories matching mask.

files(string|array $masks = ['*'])

Finds files matching the specified masks.

directories(string|array $masks = ['*'])

Finds directories matching the specified masks.

in(string|array $paths)

Searches in the given directories. Wildcards are allowed.

from(string|array $paths)

Searches recursively from the given directories. Wildcards are allowed.

childFirst(bool $state = true)

Lists directory's contents before the directory itself. By default, this is disabled.

ignoreUnreadableDirs(bool $state = true)

Ignores unreadable directories. By default, this is enabled.

sortBy(callable $callback)

Set a compare function for sorting directory entries. The function will be called to sort entries from the same directory.

sortByName()

Sorts files in each directory naturally by name.

append(string|array|null $paths = null)

Adds the specified paths or appends a new finder that returns.

exclude(string|array $masks)

Skips entries that matches the given masks relative to the ones defined with the in() or from() methods.

filter(callable $callback)

Yields only entries which satisfy the given filter.

descentFilter(callable $callback)

It descends only to directories that match the specified filter.

limitDepth(int|null $depth)

Sets the maximum depth of entries.

size(string $operator, int|null $size = null)

Restricts the search by size. $operator accepts "[operator] [size] [unit]" example: >=10kB

date(string $operator, string|int|DateTimeInterface|null $date = null)

Restricts the search by modified time. $operator accepts "[operator] [date]" example: >1978-01-23

array
collect()

Returns an array with all found files and directories.

getIterator()

No description

Details

at line 54
static Finder find(string|array $masks = ['*'])

Begins search for files and directories matching mask.

Parameters

string|array $masks

Return Value

Finder

at line 64
static Finder findFiles(string|array $masks = ['*'])

Begins search for files matching mask.

Parameters

string|array $masks

Return Value

Finder

at line 74
static Finder findDirectories(string|array $masks = ['*'])

Begins search for directories matching mask.

Parameters

string|array $masks

Return Value

Finder

at line 84
Finder files(string|array $masks = ['*'])

Finds files matching the specified masks.

Parameters

string|array $masks

Return Value

Finder

at line 93
Finder directories(string|array $masks = ['*'])

Finds directories matching the specified masks.

Parameters

string|array $masks

Return Value

Finder

at line 121
Finder in(string|array $paths)

Searches in the given directories. Wildcards are allowed.

Parameters

string|array $paths

Return Value

Finder

at line 132
Finder from(string|array $paths)

Searches recursively from the given directories. Wildcards are allowed.

Parameters

string|array $paths

Return Value

Finder

at line 155
Finder childFirst(bool $state = true)

Lists directory's contents before the directory itself. By default, this is disabled.

Parameters

bool $state

Return Value

Finder

at line 165
Finder ignoreUnreadableDirs(bool $state = true)

Ignores unreadable directories. By default, this is enabled.

Parameters

bool $state

Return Value

Finder

at line 176
Finder sortBy(callable $callback)

Set a compare function for sorting directory entries. The function will be called to sort entries from the same directory.

Parameters

callable $callback

Return Value

Finder

at line 186
Finder sortByName()

Sorts files in each directory naturally by name.

Return Value

Finder

at line 196
Finder append(string|array|null $paths = null)

Adds the specified paths or appends a new finder that returns.

Parameters

string|array|null $paths

Return Value

Finder

at line 213
Finder exclude(string|array $masks)

Skips entries that matches the given masks relative to the ones defined with the in() or from() methods.

Parameters

string|array $masks

Return Value

Finder

at line 240
Finder filter(callable $callback)

Yields only entries which satisfy the given filter.

Parameters

callable $callback

Return Value

Finder

at line 251
Finder descentFilter(callable $callback)

It descends only to directories that match the specified filter.

Parameters

callable $callback

Return Value

Finder

at line 261
Finder limitDepth(int|null $depth)

Sets the maximum depth of entries.

Parameters

int|null $depth

Return Value

Finder

at line 271
Finder size(string $operator, int|null $size = null)

Restricts the search by size. $operator accepts "[operator] [size] [unit]" example: >=10kB

Parameters

string $operator
int|null $size

Return Value

Finder

at line 291
Finder date(string $operator, string|int|DateTimeInterface|null $date = null)

Restricts the search by modified time. $operator accepts "[operator] [date]" example: >1978-01-23

Parameters

string $operator
string|int|DateTimeInterface|null $date

Return Value

Finder

at line 314
array collect()

Returns an array with all found files and directories.

Return Value

array

at line 321
Generator getIterator()

No description

Return Value

Generator

Traits

Strict class for better experience.