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 matching mask and all directories.

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 $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 58
static Finder find(string|string[] ...$masks)

Begins search for files matching mask and all directories.

Parameters

string|string[] ...$masks

Return Value

Finder

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

Begins search for files matching mask.

Parameters

string|string[] ...$masks

Return Value

Finder

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

Begins search for directories matching mask.

Parameters

string|string[] ...$masks

Return Value

Finder

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

Searches in the given folder(s).

Parameters

string|string[] ...$paths

Return Value

Finder

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

Searches recursively from the given folder(s).

Parameters

string|string[] ...$paths

Return Value

Finder

at line 138
Finder childFirst()

Shows folder content prior to the folder.

Return Value

Finder

at line 177
int count()

Get the number of found files and/or directories.

Return Value

int

at line 186
Iterator getIterator()

Returns iterator.

Return Value

Iterator

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

Restricts the search using mask.

Excludes directories from recursive traversing.

Parameters

string|string[] ...$masks

Return Value

Finder

at line 276
Finder filter(callable $callback)

Restricts the search using callback.

Parameters

callable $callback

function (RecursiveDirectoryIterator $file): bool

Return Value

Finder

at line 287
Finder limitDepth(int $depth)

Limits recursion level.

Parameters

int $depth

Return Value

Finder

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

Restricts the search by size.

Parameters

string $operator

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

int $size

Return Value

Finder

at line 322
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 341
static bool compare($l, string $operator, $r)

Compares two values.

Parameters

$l
string $operator
$r

Return Value

bool

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

No description

Parameters

string $name
array $args

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

No description

Parameters

string $name
callable $callback

Return Value

void

Traits

Strict class for better experience.