Skip to content

Commit 07aad34

Browse files
committed
Merge pull request #3 from mbed67/readme
Readme
2 parents 47e2171 + 91ea61d commit 07aad34

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,69 @@
1-
# FlyFinder
1+
FlyFinder
2+
================================================================================================================
3+
4+
FlyFinder is a plugin for [Flysystem](http://flysystem.thephpleague.com/) that will enable you to find files
5+
based on certain criteria.
6+
7+
FlyFinder can search for files and directories that are hidden, that have a certain extension or that exist in a
8+
certain path.
9+
10+
## Installation
11+
12+
The easiest way to install this library is with [Composer](https://getcomposer.org) using the following command:
13+
14+
$ composer require phpdocumentor/flyfinder
15+
16+
## Examples
17+
18+
Ready to dive in and don't want to read through all that text below? Just consult the [examples](examples) folder and
19+
check which type of action that your want to accomplish.
20+
21+
## Usage
22+
23+
In order to use the FlyFinder plugin you first need a Flyfinder filesystem with an adapter,
24+
for instance the local adapter.
25+
26+
use League\Flysystem\Filesystem;
27+
use League\Flysystem\Adapter;
28+
use Flyfinder\Finder;
29+
30+
$filesystem = new Filesystem(new Adapter\Local(__DIR__.'/path/to/files/'));
31+
32+
Now you can add the plugin as follows:
33+
34+
$filesystem->addPlugin(new Finder());
35+
36+
FlyFinder will need specifications to know what to look for. The following specifications are available:
37+
38+
- IsHidden (this specification will return `true` when a file or directory is hidden,
39+
- HasExtension (this specification will return `true` when a file or directory has the specified extension),
40+
- InPath (this specification will return `true` when a file is in the given path. Wildcards are allowed.)
41+
42+
Specifications can be instantiated as follows:
43+
44+
use Flyfinder\Path;
45+
use Flyfinder\Specification\IsHidden;
46+
use Flyfinder\Specification\HasExtension;
47+
use Flyfinder\Specification\InPath;
48+
49+
$isHidden = new IsHidden();
50+
$hasExtension = new HasExtension(['txt']);
51+
$inPath = new InPath(new Path('mydir'));
52+
53+
### Combining specifications
54+
55+
You can search on more criteria by combining the specifications. Specifications can be chained as follows:
56+
57+
`$isHidden->andSpecification($hasExtension)` will find all files and directories that are hidden AND have the given
58+
extension.
59+
60+
`$isHidden->orSpecification($hasExtension)` will find all files and directories that are hidden OR have the given
61+
extension.
62+
63+
`$isHidden->notSpecification` will find all files and directories that are NOT hidden.
64+
65+
You can also make longer chains like this:
66+
67+
` $specification = $inPath->andSpecification($hasExtension)->andSpecification($isHidden->notSpecification());`
68+
69+
This will find all files in the given path, that have the given extension and are not hidden.

tests/unit/Specification/InPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testIfSpecificationIsNotSatisfied($dirname)
7373
}
7474

7575
/**
76-
* Data provider for testIfSpecificationIsNotSatisfied. Contains a few valid directory names
76+
* Data provider for testIfSpecificationIsNotSatisfied. Contains a few invalid directory names
7777
*
7878
* @return array
7979
*/

0 commit comments

Comments
 (0)