ILIAS  release_7 Revision v7.30-3-g800a261c036
RecursiveDirectoryIterator.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
5
8
15{
17 private $filesystem;
18
20 protected $dir;
21
23 protected $files = [];
24
30 public function __construct(Filesystem $filesystem, string $dir)
31 {
32 $this->filesystem = $filesystem;
33 $this->dir = $dir;
34 }
35
39 public function key()
40 {
41 return key($this->files);
42 }
43
47 public function next()
48 {
49 next($this->files);
50 }
51
56 public function current()
57 {
58 return current($this->files);
59 }
60
64 public function valid()
65 {
66 return $this->current() instanceof Metadata;
67 }
68
72 public function rewind()
73 {
74 $contents = $this->filesystem->listContents($this->dir, false);
75 $this->files = array_combine(array_map(function (Metadata $metadata) {
76 return $metadata->getPath();
77 }, $contents), $contents);
78 }
79
83 public function hasChildren()
84 {
85 return $this->current()->isDir();
86 }
87
91 public function getChildren()
92 {
93 return new self($this->filesystem, $this->current()->getPath());
94 }
95}
An exception for terminatinating execution or to throw for unit testing.
Class Metadata This class holds all default metadata send by the filesystem adapters.
Definition: Metadata.php:17
getPath()
The path to the file or directory.
Definition: Metadata.php:53
__construct(Filesystem $filesystem, string $dir)
RecursiveDirectoryIterator constructor.
Interface Filesystem The filesystem interface provides the public interface for the Filesystem servic...
Definition: Filesystem.php:22
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...