3 declare(strict_types=1);
51 private array
$vcsPatterns = [
'.svn',
'_svn',
'CVS',
'_darcs',
'.arch-params',
'.monotone',
'.bzr',
'.git',
'.hg'];
73 $this->ignore = self::IGNORE_VCS_FILES | self::IGNORE_DOT_FILES;
105 public function exclude(array $directories): self
107 array_walk($directories,
static function ($directory):
void {
108 if (!is_string($directory)) {
109 if (is_object($directory)) {
117 $clone = clone $this;
118 $clone->exclude = array_merge($clone->exclude, $directories);
128 public function in(array $directories): self
130 array_walk($directories,
static function ($directory):
void {
131 if (!is_string($directory)) {
132 if (is_object($directory)) {
140 $clone = clone $this;
141 $clone->dirs = array_unique(array_merge($clone->dirs, $directories));
160 $clone = clone $this;
182 public function date(
string $date): self
184 $clone = clone $this;
204 public function size($sizes): self
206 if (!is_array($sizes)) {
210 $clone = clone $this;
212 foreach ($sizes as $size) {
221 $clone = clone $this;
222 $clone->reverseSorting =
true;
229 $clone = clone $this;
231 $clone->ignore |= self::IGNORE_VCS_FILES;
246 array_walk($pattern,
static function ($p):
void {
247 if (!is_string($p)) {
256 $clone = clone $this;
257 foreach ($pattern as $p) {
258 $clone->vcsPatterns[] = $p;
261 $clone->vcsPatterns = array_unique($clone->vcsPatterns);
275 $clone = clone $this;
276 $clone->sort = $closure;
281 public function sortByName(
bool $useNaturalSort =
false): self
283 $clone = clone $this;
285 if ($useNaturalSort) {
294 $clone = clone $this;
302 $clone = clone $this;
315 public function append(iterable $iterator): self
317 $clone = clone $this;
320 $clone->iterators[] = $iterator->getIterator();
322 $clone->iterators[] = $iterator;
323 } elseif ($iterator instanceof
Traversable || is_array($iterator)) {
325 foreach ($iterator as $file) {
332 $clone->iterators[] = $it;
342 if (self::IGNORE_VCS_FILES === (self::IGNORE_VCS_FILES & $this->ignore)) {
377 $iterator = $iteratorAggregate->getIterator();
388 #[\ReturnTypeWillChange] 391 if (0 ===
count($this->dirs) && 0 ===
count($this->iterators)) {
392 throw new LogicException(
'You must call one of in() or append() methods before iterating over a Finder.');
395 if (1 ===
count($this->dirs) && 0 ===
count($this->iterators)) {
400 foreach ($this->dirs as $dir) {
404 foreach ($this->iterators as $it) {
405 $iterator->append($it);
size($sizes)
Adds tests for file sizes.
depth($level)
Adds tests for the directory depth.
ignoreVCS(bool $ignoreVCS)
__construct(Filesystem $filesystem)
sort(Closure $closure)
Sorts files and directories by an anonymous function.
const SORT_BY_NAME_NATURAL
addVCSPattern(array $pattern)
searchInDirectory(string $dir)
ILIAS Filesystem Filesystem $filesystem
exclude(array $directories)
date(string $date)
Adds tests for file dates.
append(iterable $iterator)
Appends an existing set of files/directories to the finder.
Class FlySystemFileAccessTest disabled disabled disabled.
sortByName(bool $useNaturalSort=false)