Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Adapter / PhpAdapter.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Finder\Adapter;
13
14 @trigger_error('The '.__NAMESPACE__.'\PhpAdapter class is deprecated since version 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
15
16 use Symfony\Component\Finder\Iterator;
17
18 /**
19  * PHP finder engine implementation.
20  *
21  * @author Jean-François Simon <contact@jfsimon.fr>
22  *
23  * @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
24  */
25 class PhpAdapter extends AbstractAdapter
26 {
27     /**
28      * {@inheritdoc}
29      */
30     public function searchInDirectory($dir)
31     {
32         $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
33
34         if ($this->followLinks) {
35             $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
36         }
37
38         $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
39
40         if ($this->exclude) {
41             $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
42         }
43
44         $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
45
46         if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
47             $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
48         }
49
50         if ($this->mode) {
51             $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
52         }
53
54         if ($this->names || $this->notNames) {
55             $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
56         }
57
58         if ($this->contains || $this->notContains) {
59             $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
60         }
61
62         if ($this->sizes) {
63             $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
64         }
65
66         if ($this->dates) {
67             $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
68         }
69
70         if ($this->filters) {
71             $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
72         }
73
74         if ($this->paths || $this->notPaths) {
75             $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
76         }
77
78         if ($this->sort) {
79             $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
80             $iterator = $iteratorAggregate->getIterator();
81         }
82
83         return $iterator;
84     }
85
86     /**
87      * {@inheritdoc}
88      */
89     public function getName()
90     {
91         return 'php';
92     }
93
94     /**
95      * {@inheritdoc}
96      */
97     protected function canBeUsed()
98     {
99         return true;
100     }
101 }