class Finder implements IteratorAggregate

Searches for files and directories in directory trees.

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)

Sets a comparison function for sorting entries within each directory.

sortByName()

Sorts files in each directory naturally by name.

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

Appends the specified file paths to results. Passing null creates and returns a new sub-finder whose results are appended.

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 53
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 75
static Finder findDirectories(string|array $masks = ['*'])

Begins search for directories matching mask.

Parameters

string|array $masks

Return Value

Finder

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

Finds files matching the specified masks.

Parameters

string|array $masks

Return Value

Finder

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

Finds directories matching the specified masks.

Parameters

string|array $masks

Return Value

Finder

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

Searches in the given directories. Wildcards are allowed.

Parameters

string|array $paths

Return Value

Finder

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

Searches recursively from the given directories. Wildcards are allowed.

Parameters

string|array $paths

Return Value

Finder

at line 162
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 172
Finder ignoreUnreadableDirs(bool $state = true)

Ignores unreadable directories. By default, this is enabled.

Parameters

bool $state

Return Value

Finder

at line 183
Finder sortBy(callable $callback)

Sets a comparison function for sorting entries within each directory.

Parameters

callable $callback

Return Value

Finder

at line 193
Finder sortByName()

Sorts files in each directory naturally by name.

Return Value

Finder

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

Appends the specified file paths to results. Passing null creates and returns a new sub-finder whose results are appended.

Parameters

string|array|null $paths

Return Value

Finder

at line 222
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 249
Finder filter(callable $callback)

Yields only entries which satisfy the given filter.

Parameters

callable $callback

Return Value

Finder

at line 260
Finder descentFilter(callable $callback)

It descends only to directories that match the specified filter.

Parameters

callable $callback

Return Value

Finder

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

Sets the maximum depth of entries.

Parameters

int|null $depth

Return Value

Finder

at line 281
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 302
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 325
array collect()

Returns an array with all found files and directories.

Return Value

array

at line 332
Generator getIterator()

No description

Return Value

Generator