files[$file] = $hotFile; $hotFile ->on(HotFile::EVENT_CHANGED, fn (HotFile $file) => $this->emit(self::EVENT_FILE_CHANGED, [$this, $file])) ->on(HotFile::EVENT_REMOVED, fn (HotFile $file) => $this->emit(self::EVENT_FILE_REMOVED, [$this, $file])); } Loop::addPeriodicTimer($interval, function () use ($interval) { foreach (FileSystemUtils::getAllFiles($this->directory) as $file) { if (isset($this->files[$file])) { continue; } $this->files[$file] = new HotFile($file, $interval); $this->emit(self::EVENT_FILE_ADDED, [$this, $file]); } }); } /** * @return HotFile[] */ public function getFiles(): array { return $this->files; } }