Download the PHP package org_heigl/filefinder without Composer
On this page you can find all versions of the php package org_heigl/filefinder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package filefinder
Org_Heigl\FileFinder
This library allows to iterate through a number of folders and filter the list of files. The files are returned in a filelist-object.
Installation
Org_Heigl\FileFinder is installed via composer. Call from the commandline in your project.
Alternatively you can include the following line in your inside the -section:
"org_heigl/filefinder" : "stable"
Usage
Simplest usage would be to add a filter to the FileFinder as well as a directory.
$dir
You can also set your own -Object as long as it implements . That would then look like this:
$dir
You can also get a mapping of classname to filename for all classes implementing underneath the directory using this snippet:
The directories added with the -method will be recursively checked.
The filters have to implement . Therefore you can add your own filters very easily.
The default -implementation also contains a -method that allows sorting the filelist before using it. Just provide an implementation of the as argument like this:
Contains
Currently the library contains the following filters:
- FileExtension - A filter to check whether the files extension is one of a given number of extensions. The list of extensions if given to the constructor like so: .
- FileStart - A filter that checks whether the files content starts with the given string. You could use it like this: to check for a PHP-file.
- ClassIsInstanceOf - A filter to check whether the file contains a class that implements at least one of the looked for Interfaces. The interfaces can be given like this: .
- DateCompare - A filter that compares the files create-, modification- or alter-date with the given date. Comparison can be either before, after or equals. So it can be invoked like this: . That will include files whose content has been altered before the current date (which schould include everything(-; )
- FileSize - Find files with a filesize within the given range: It can be used like this: which will find files between 1kB and 2GB in size.
- HoldsSinglePHPClass - Find files that old only one class. Files with more than one class will be ommited.
- MimeType - Find files of a certain mime-Type. You can use it like this: That will find all PDF-files. This filter requires a FinfoWrapper-Object as first object that will handle the actual mime-type detection.
- Not - Negate the contained filters.
- OrList - Holds a number of filters where only one needs to match to include the file in the list.
License
This library is licensed under the MIT-License as found in the LICENSE-File.
Issues
You have an issue? Use the Issuetracker to report it and we'll see for it.
Contributing
Contributions are always welcome. Fork the repo, do whatever you like and open a pull request!