file = $file; } public function getConfiguration(): Configuration { if ($this->file !== null) { return $this->loadConfiguration($this->file); } /** * If no config has been provided, look for default config file in the path. */ $defaultFiles = [ 'migrations.xml', 'migrations.yml', 'migrations.yaml', 'migrations.json', 'migrations.php', ]; foreach ($defaultFiles as $file) { if ($this->configurationFileExists($file)) { return $this->loadConfiguration($file); } } throw MissingConfigurationFile::new(); } private function configurationFileExists(string $config): bool { return file_exists($config); } /** * @throws FileTypeNotSupported */ private function loadConfiguration(string $file): Configuration { return (new FormattedFile($file))->getConfiguration(); } }