Finder
class Finder implements IteratorAggregate
Finder allows searching through directory trees using iterator.
Finder::findFiles('*.php') ->size('> 10kB') ->from('.') ->exclude('temp');
Methods
Begins search for files and directories matching mask.
Begins search for directories matching mask.
Finds directories matching the specified masks.
Searches recursively from the given directories. Wildcards are allowed.
Lists directory's contents before the directory itself. By default, this is disabled.
Ignores unreadable directories. By default, this is enabled.
Set a compare function for sorting directory entries. The function will be called to sort entries from the same directory.
Sorts files in each directory naturally by name.
Adds the specified paths or appends a new finder that returns.
Skips entries that matches the given masks relative to the ones defined with the in() or from() methods.
It descends only to directories that match the specified filter.
Sets the maximum depth of entries.
Restricts the search by size. $operator accepts "[operator] [size] [unit]" example: >=10kB
Restricts the search by modified time. $operator accepts "[operator] [date]" example: >1978-01-23
Returns an array with all found files and directories.
No description
Details
at line 54
static Finder
find(string|array $masks = ['*'])
Begins search for files and directories matching mask.
at line 64
static Finder
findFiles(string|array $masks = ['*'])
Begins search for files matching mask.
at line 74
static Finder
findDirectories(string|array $masks = ['*'])
Begins search for directories matching mask.
at line 84
Finder
files(string|array $masks = ['*'])
Finds files matching the specified masks.
at line 93
Finder
directories(string|array $masks = ['*'])
Finds directories matching the specified masks.
at line 121
Finder
in(string|array $paths)
Searches in the given directories. Wildcards are allowed.
at line 132
Finder
from(string|array $paths)
Searches recursively from the given directories. Wildcards are allowed.
at line 155
Finder
childFirst(bool $state = true)
Lists directory's contents before the directory itself. By default, this is disabled.
at line 165
Finder
ignoreUnreadableDirs(bool $state = true)
Ignores unreadable directories. By default, this is enabled.
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.
at line 186
Finder
sortByName()
Sorts files in each directory naturally by name.
at line 196
Finder
append(string|array|null $paths = null)
Adds the specified paths or appends a new finder that returns.
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.
at line 240
Finder
filter(callable $callback)
Yields only entries which satisfy the given filter.
at line 251
Finder
descentFilter(callable $callback)
It descends only to directories that match the specified filter.
at line 261
Finder
limitDepth(int|null $depth)
Sets the maximum depth of entries.
at line 271
Finder
size(string $operator, int|null $size = null)
Restricts the search by size. $operator accepts "[operator] [size] [unit]" example: >=10kB
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
at line 314
array
collect()
Returns an array with all found files and directories.
at line 321
Generator
getIterator()
No description
Traits
Strict class for better experience.