protected function getPackageKeyFromMigrationVersion(Version $version)
    {
        $sortedAvailablePackages = $this->packageManager->getAvailablePackages();
        usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
            return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
        });

        $reflectedClass = new \ReflectionClass($version->getMigration());
        $classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());

        /** @var $package PackageInterface */
        foreach ($sortedAvailablePackages as $package) {
            $packagePath = Files::getUnixStylePath($package->getPackagePath());
            if (strpos($classPathAndFilename, $packagePath) === 0) {
                return $package->getPackageKey();
            }
        }

        return '';
    }
protected function getPackageKeyFromMigrationVersion(Version $version)
    {
        $sortedAvailablePackages = $this->packageManager->getAvailablePackages();
        usort($sortedAvailablePackages, function (PackageInterface $packageOne, PackageInterface $packageTwo) {
            return strlen($packageTwo->getPackagePath()) - strlen($packageOne->getPackagePath());
        });

        $reflectedClass = new \ReflectionClass($version->getMigration());
        $classPathAndFilename = Files::getUnixStylePath($reflectedClass->getFileName());

        /** @var $package PackageInterface */
        foreach ($sortedAvailablePackages as $package) {
            $packagePath = Files::getUnixStylePath($package->getPackagePath());
            if (strpos($classPathAndFilename, $packagePath) === 0) {
                return $package->getPackageKey();
            }
        }

        return '';
    }
protected function getPackageKeyFromMigrationVersion ( Version $ version ) { $ sortedAvailablePackages = $ this -> packageManager -> getAvailablePackages ( ) ; usort ( $ sortedAvailablePackages , function ( PackageInterface $ packageOne , PackageInterface $ packageTwo ) { return strlen ( $ packageTwo -> getPackagePath ( ) ) - strlen ( $ packageOne -> getPackagePath ( ) ) ; } ) ; $ reflectedClass = new \ ReflectionClass ( $ version -> getMigration ( ) ) ; $ classPathAndFilename = Files :: getUnixStylePath ( $ reflectedClass -> getFileName ( ) ) ; /** @var $package PackageInterface */ foreach ( $ sortedAvailablePackages as $ package ) { $ packagePath = Files :: getUnixStylePath ( $ package -> getPackagePath ( ) ) ; if ( strpos ( $ classPathAndFilename , $ packagePath ) === 0 ) { return $ package -> getPackageKey ( ) ; } } return '' ; }
Tries to find out a package key which the Version belongs to. If no
package could be found, an empty string is returned.

@param Version $version
@return string
@throws \ReflectionException
Tries to find out a package key which the Version belongs to . If no package could be found an empty string is returned .