src/Composer/Downloader/DownloadManager.php
public function getDownloaderForInstalledPackage(PackageInterface $package)
    {
        $installationSource = $package->getInstallationSource();

        if ('metapackage' === $package->getType()) {
            return;
        }

        if ('dist' === $installationSource) {
            $downloader = $this->getDownloader($package->getDistType());
        } elseif ('source' === $installationSource) {
            $downloader = $this->getDownloader($package->getSourceType());
        } else {
            throw new \InvalidArgumentException(
                'Package '.$package.' seems not been installed properly'
            );
        }

        if ($installationSource !== $downloader->getInstallationSource()) {
            throw new \LogicException(sprintf(
                'Downloader "%s" is a %s type downloader and can not be used to download %s',
                get_class($downloader), $downloader->getInstallationSource(), $installationSource
            ));
        }

        return $downloader;
    }
public function getDownloaderForInstalledPackage(PackageInterface $package)
    {
        $installationSource = $package->getInstallationSource();

        if ('metapackage' === $package->getType()) {
            return;
        }

        if ('dist' === $installationSource) {
            $downloader = $this->getDownloader($package->getDistType());
        } elseif ('source' === $installationSource) {
            $downloader = $this->getDownloader($package->getSourceType());
        } else {
            throw new \InvalidArgumentException(
                'Package '.$package.' seems not been installed properly'
            );
        }

        if ($installationSource !== $downloader->getInstallationSource()) {
            throw new \LogicException(sprintf(
                'Downloader "%s" is a %s type downloader and can not be used to download %s',
                get_class($downloader), $downloader->getInstallationSource(), $installationSource
            ));
        }

        return $downloader;
    }
public function getDownloaderForInstalledPackage ( PackageInterface $ package ) { $ installationSource = $ package -> getInstallationSource ( ) ; if ( 'metapackage' === $ package -> getType ( ) ) { return ; } if ( 'dist' === $ installationSource ) { $ downloader = $ this -> getDownloader ( $ package -> getDistType ( ) ) ; } elseif ( 'source' === $ installationSource ) { $ downloader = $ this -> getDownloader ( $ package -> getSourceType ( ) ) ; } else { throw new \ InvalidArgumentException ( 'Package ' . $ package . ' seems not been installed properly' ) ; } if ( $ installationSource !== $ downloader -> getInstallationSource ( ) ) { throw new \ LogicException ( sprintf ( 'Downloader "%s" is a %s type downloader and can not be used to download %s' , get_class ( $ downloader ) , $ downloader -> getInstallationSource ( ) , $ installationSource ) ) ; } return $ downloader ; }
Returns downloader for already installed package.

@param  PackageInterface         $package package instance
@return DownloaderInterface|null

@throws \InvalidArgumentException if package has no installation source specified
@throws \LogicException           if specific downloader used to load package with
wrong type
Returns downloader for already installed package .