original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Returns downloader for already installed package .