dir = $dir; } public function getMigrations(): array { $migrations = []; foreach (new \DirectoryIterator($this->dir) as $file) { if ($file->getExtension() !== 'sql') { continue; } $version = pathinfo($file->getBasename(), PATHINFO_FILENAME); $migrations[$version] = $file->getPathname(); } ksort($migrations); return $migrations; } public function getMigration(string $version): string { $migrations = $this->getMigrations(); if (!array_key_exists($version, $migrations)) { throw new \InvalidArgumentException("Version '$version' does not exist."); } return $migrations[$version]; } /** * @return string */ public function getDir(): string { return $this->dir; } }