public function getMigrations()
    {
        if (count($this->_migrations) <= 0 && $this->_config !== null) {
            $versions = [];
            $paths = $this->_config->getMigrationPaths();
            foreach ($paths as $path) {
                $files = glob($path . '/*.php');
                foreach ($files as $file) {
                    $fileName = basename($file);
                    if (Util::isValidMigrationFileName($fileName)) {
                        $version = Util::getVersionFromFileName($fileName);
                        if (Arr::key($version, $versions)) {
                            throw new \InvalidArgumentException(
                                __d(
                                    'extensions',
                                    'Duplicate migration - "%s" has the same version as "%s"',
                                    $file,
                                    $versions[$version]->getVersion()
                                )
                            );
                        }

                        //  Convert the filename to a class name.
                        $class = Util::mapFileNameToClassName($fileName);

                        /** @noinspection PhpIncludeInspection */
                        require_once $file;
                        if (!class_exists($class)) {
                            throw new \InvalidArgumentException(
                                __d('extensions', 'Could not find class "%s" in file "%s"', $class, $file)
                            );
                        }

                        //  Instantiate migration class.
                        $migration = new $class($version);
                        if (!($migration instanceof AbstractMigration)) {
                            throw new \InvalidArgumentException(
                                __d(
                                    'extensions',
                                    'The class "%s" in file "%s" must extend \Phinx\Migration\AbstractMigration',
                                    $class,
                                    $file
                                )
                            );
                        }

                        $versions[$version] = $migration;
                    }
                }
            }

            ksort($versions);
            $this->_migrations = $versions;
        }

        return $this->_migrations;
    }