Methods summary
public
|
#
__construct( )
Finder constructor.
No parameters needed.
Finder constructor.
No parameters needed.
|
public static
KeepItSimple\FileSystem\Finder
|
#
create( )
Create a Finder instance and returns it.
Equivalent to :
$finder = (new Finder())->in(__DIR__);
Create a Finder instance and returns it.
Equivalent to :
$finder = (new Finder())->in(__DIR__);
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
files( )
Restricts the matching to files only.
Restricts the matching to files only.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
directories( )
Restricts the matching to directories only.
Restricts the matching to directories only.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
in( string|array $directories )
Searches files and/or directories in the given path(s).
Searches files and/or directories in the given path(s).
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
exclude( $directories )
Searches files and/or directories except in the given path(s).
Searches files and/or directories except in the given path(s).
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
ignoreUnreadableDirs( boolean $yes = true )
Tells Finder to ignore (or not) unreadable directories.
Tells Finder to ignore (or not) unreadable directories.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
ignoreDots( boolean $yes = true )
Tells Finder to ignore (or not) dot directories.
Will remove current directory and parent directory ("." and "..") as well as file starting with ".".
Tells Finder to ignore (or not) dot directories.
Will remove current directory and parent directory ("." and "..") as well as file starting with ".".
Parameters
Returns
Uses
FilesystemIterator::SKIP_DOTS
|
public
KeepItSimple\FileSystem\Finder
|
#
ignoreVCS( boolean $yes = true )
Tells Finder to ignore (or not) VCS files.
Tells Finder to ignore (or not) VCS files.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
followLinks( boolean $yes = true )
Tells Finder to follow (or not) symbolic links.
Tells Finder to follow (or not) symbolic links.
Parameters
Returns
Uses
FilesystemIterator::FOLLOW_SYMLINKS
|
public
KeepItSimple\FileSystem\Finder
|
#
sort( callable $callback )
Sorts files and directories from a user defined function.
The anonymous function receives two \SplFileInfo instances to compare.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories from a user defined function.
The anonymous function receives two \SplFileInfo instances to compare.
This can be slow as all the matching files and directories must be retrieved for comparison.
Parameters
Returns
Uses
ArrayIterator::uasort()
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByName( )
Sorts files and directories by name.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by name.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByType( )
Sorts files and directories by type.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by type.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortBySize( )
Sorts files and directories by size.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by size.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByExtension( )
Sorts files and directories by file extension.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by file extension.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByPath( )
Sorts files and directories by path (without file name).
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by path (without file name).
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByPermission( )
Sorts files and directories by permissions.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by permissions.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByAccessedTime( )
Sorts files and directories by accessed time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by accessed time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByModifiedTime( )
Sorts files and directories by modified time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by modified time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
sortByChangedTime( )
Sorts files and directories by changed time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Sorts files and directories by changed time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
filter( callable $callback )
Filters the iterator with a user defined function.
The anonymous function receives a SplFileInfo and must return false to remove files.
Filters the iterator with a user defined function.
The anonymous function receives a SplFileInfo and must return false to remove files.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
withName( string $name )
Adds rules that files name must match.
You can use patterns regex, globs or simple strings.
Example :
$finder->withName('*.php')
will produce same result as
$finder->name('/.php$/')
Adds rules that files name must match.
You can use patterns regex, globs or simple strings.
Example :
$finder->withName('*.php')
will produce same result as
$finder->name('/.php$/')
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
withoutName( $name )
Adds rules that files name must NOT match.
You can use patterns regex, globs or simple strings.
Example :
$finder->withoutName('*.php')
will produce same result as
$finder->name('/.php$/')
Adds rules that files name must NOT match.
You can use patterns regex, globs or simple strings.
Example :
$finder->withoutName('*.php')
will produce same result as
$finder->name('/.php$/')
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
contains( string $pattern )
Adds rules that files content must match.
You can use patterns regex or simple strings.
Example :
$finder->contains('Hello World')
will produce same result as
$finder->name('/Hello World/i')
Adds rules that files content must match.
You can use patterns regex or simple strings.
Example :
$finder->contains('Hello World')
will produce same result as
$finder->name('/Hello World/i')
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
doesNotContain( $pattern )
Adds rules that files content must NOT match.
You can use patterns regex or simple strings.
Example :
$finder->doesNotContain('Hello World')
will produce same result as
$finder->name('/Hello World/i')
Adds rules that files content must NOT match.
You can use patterns regex or simple strings.
Example :
$finder->doesNotContain('Hello World')
will produce same result as
$finder->name('/Hello World/i')
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
withPath( string $path )
Restrict files and directories by path.
You can use patterns regex or simple strings.
Restrict files and directories by path.
You can use patterns regex or simple strings.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
withoutPath( string $path )
Exclude files and directories by path.
You can use patterns regex or simple strings.
Exclude files and directories by path.
You can use patterns regex or simple strings.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
date( string $date )
Adds tests for file dates (last modified).
Remove the file if
$current->getCTime() >= strtotime($date)
.
The date must be something that strtotime() is able to parse.
Adds tests for file dates (last modified).
Remove the file if
$current->getCTime() >= strtotime($date)
.
The date must be something that strtotime() is able to parse.
Parameters
Returns
|
public
KeepItSimple\FileSystem\Finder
|
#
size( string $size )
Adds tests for file sizes in bytes.
Remove the file if
$current->getSize() >= $size
.
Adds tests for file sizes in bytes.
Remove the file if
$current->getSize() >= $size
.
Parameters
Returns
|
public
|
#
depth( integer $depth )
Set the maximum allowed depth.
Set the maximum allowed depth.
Parameters
Returns
$this
|
public
KeepItSimple\FileSystem\Finder
|
#
merge( KeepItSimple\FileSystem\Finder|Iterator|array $iterator )
Merge an other Finder or Iterator or simple array instance with the current Finder instance.
Merge an other Finder or Iterator or simple array instance with the current Finder instance.
Parameters
Returns
Throws
InvalidArgumentException
|
public
Iterator
|
#
getIterator( )
Retrieve an external iterator.
Retrieve an external iterator.
Returns
Iterator An instance of an object implementing Iterator
Since
5.0.0
Link
Implementation of
IteratorAggregate::getIterator()
|
public
integer
|
#
count( )
Count elements of an object.
Count elements of an object.
Returns
integer The custom count as an integer.
Since
5.1.0
Link
Implementation of
Countable::count()
|