class Finder implements IteratorAggregate, Countable

Finder allows searching through directory trees using iterator.

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

Methods

static Finder
find(string|string[] ...$masks)

Begins search for files and directories matching mask.

static Finder
findFiles(string|string[] ...$masks)

Begins search for files matching mask.

static Finder
findDirectories(string|string[] ...$masks)

Begins search for directories matching mask.

in(string|string[] ...$paths)

Searches in the given folder(s).

from(string|string[] ...$paths)

Searches recursively from the given folder(s).

childFirst()

Shows folder content prior to the folder.

int
count()

Get the number of found files and/or directories.

getIterator()

Returns iterator.

exclude(string|string[] ...$masks)

Restricts the search using mask.

filter(callable $callback)

Restricts the search using callback.

limitDepth(int $depth)

Limits recursion level.

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

Restricts the search by size.

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

Restricts the search by modified time.

static bool
compare($l, string $operator, $r)

Compares two values.

__call(string $name, array $args)

No description

static void
extensionMethod(string $name, callable $callback)

No description

Details

at line 60
static Finder find(string|string[] ...$masks)

Begins search for files and directories matching mask.

Parameters

string|string[] ...$masks

Return Value

Finder

at line 72
static Finder findFiles(string|string[] ...$masks)

Begins search for files matching mask.

Parameters

string|string[] ...$masks

Return Value

Finder

at line 84
static Finder findDirectories(string|string[] ...$masks)

Begins search for directories matching mask.

Parameters

string|string[] ...$masks

Return Value

Finder

at line 113
Finder in(string|string[] ...$paths)

Searches in the given folder(s).

Parameters

string|string[] ...$paths

Return Value

Finder

at line 125
Finder from(string|string[] ...$paths)

Searches recursively from the given folder(s).

Parameters

string|string[] ...$paths

Return Value

Finder

at line 141
Finder childFirst()

Shows folder content prior to the folder.

Return Value

Finder

at line 184
int count()

Get the number of found files and/or directories.

Return Value

int

at line 193
Iterator getIterator()

Returns iterator.

Return Value

Iterator

at line 268
Finder exclude(string|string[] ...$masks)

Restricts the search using mask.

Excludes directories from recursive traversing.

Parameters

string|string[] ...$masks

Return Value

Finder

at line 287
Finder filter(callable $callback)

Restricts the search using callback.

Parameters

callable $callback

function (RecursiveDirectoryIterator $file): bool

Return Value

Finder

at line 298
Finder limitDepth(int $depth)

Limits recursion level.

Parameters

int $depth

Return Value

Finder

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

Restricts the search by size.

Parameters

string $operator

"[operator] [size] [unit]" example: >=10kB

int|null $size

Return Value

Finder

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

Restricts the search by modified time.

Parameters

string $operator

"[operator] [date]" example: >1978-01-23

string|int|DateTimeInterface $date

Return Value

Finder

at line 355
static bool compare($l, string $operator, $r)

Compares two values.

Parameters

$l
string $operator
$r

Return Value

bool

at line 382
__call(string $name, array $args)

No description

Parameters

string $name
array $args

at line 390
static void extensionMethod(string $name, callable $callback)

No description

Parameters

string $name
callable $callback

Return Value

void

Traits

Strict class for better experience.