Check if this patch is for a package.

@param \Composer\Package\PackageInterface $package

@return bool
968599
public function isForPackage(PackageInterface $package)
    {
        if ($this->getForPackage() !== $package->getName()) {
            return false;
        }
        $fpv = $this->getForPackageVersion();
        if ($fpv !== null) {
            $pv = new Constraint('=', $package->getVersion());
            if (!$fpv->matches($pv)) {
                return false;
            }
        }

        return true;
    }
69654
protected static function isAsset(PackageInterface $package)
    {
        foreach (Assets::getTypes() as $type) {
            $type = Assets::createType($type);

            if ($package->getType() === $type->getComposerType()) {
                return true;
            }
        }

        return false;
    }
1058886
public function unlockPackage(PackageInterface $package)
    {
        $name = $package->getPrettyName();
        $lock = 'extra/tenside/version-locks/' . $this->escape($name);

        // Nothing to do?
        if (!$this->has($lock)) {
            return $this;
        }

        if (false === ($constraint = $this->get($lock))) {
            $this->remove($lock);
            $this->requirePackage($name, null);
            $this->cleanEmptyArraysInPath('extra/tenside');

            return $this;
        }

        $this->requirePackage($name, $constraint);
        $this->remove($lock);
        $this->cleanEmptyArraysInPath('extra/tenside');

        return $this;
    }
379914
public static function createFromComposerPackage(CompletePackageInterface $package)
    {
        $class = new self();
        $class->type = $package->getType();
        $class->name = $package->getPrettyName();
        $class->description = $package->getDescription();
        $class->authors = $package->getAuthors();
        $class->keywords = $package->getKeywords();
        if ($package->getVersion() === '9999999-dev') {
            $class->version = sprintf('%s (%s)', $package->getPrettyVersion(), substr($package->getSourceReference(), 0, 6));
        } else {
            $class->version = $package->getPrettyVersion();
        }

        return $class;
    }
1203067
protected function getInstallerConfig(PackageInterface $package)
    {
        if ($this->installerConfig !== null) {
            return $this->installerConfig;
        }

        $type       = $package->getType();
        $prettyName = $package->getPrettyName();

        if (strpos($prettyName, '/') !== false) {
            list($vendor, $name) = explode('/', $prettyName);
        } else {
            $vendor = '';
            $name   = $prettyName;
        }

        $extra = $package->getExtra();

        if (!empty($extra['installer-name'])) {
            $name = $extra['installer-name'];
        }

        $loader = 'mu-plugins/' . $name . '.php';

        if (!empty($extra['installer-loader'])) {
            $loader = $extra['installer-loader'];
        }

        return compact('name', 'vendor', 'type', 'loader');
    }
956606
private function findSubPackages(PackageInterface $package): Generator
    {
        $readMes = new \Symfony\Component\Finder\Finder();
        $readMes->files()
                ->in($package->getPaths())
                ->depth(1)
                ->name('readme.md');

        // If no sub-folders have a readme, there aren't any sub-packages here.
        if (!$readMes->count()) {
            return;
        }
        yield from $this->scanNamespaceForPackages($package, $package);
    }
540399
public function packageExists($namespace, $package)
    {
        $folder = $this->vendorFolder . $namespace;
        $folderExists = file_exists($folder);

        if (!$folderExists) {
            return false;
        }

        $packageFolder = $folder . '/' . $package;
        $packageFolderExists = file_exists($packageFolder);

        return $packageFolderExists;
    }
775
protected function isUploadedFile($package)
    {
        if (isset($package['name'], $package['tmp_name'], $package['type'], $package['size'])) {
            if (in_array($package['type'], ['application/zip', 'application/x-zip-compressed'])) {
                return true;
            }
        }

        return false;
    }
632780
public function remove($package)
    {
        $output = $this->runCommand(self::REMOVE, $package, self::REMOVE_ARGS);

        if (!$output) {
            return true;
        }

        return false;
    }
935205
public function writelnInstalledPackage(PackageInterface $package)
    {
        $this->output->writeln(sprintf('bower <info>%s</info> <fg=cyan>%s</fg=cyan>',
            str_pad($package->getName() . '#' . $package->getVersion(), 21, ' ', STR_PAD_RIGHT),
            str_pad('install', 10, ' ', STR_PAD_LEFT)
        ));
    }
116
public function getPattern(PackageInterface $package)
    {
        if (isset($this->packages[$package->getName()])) {
            return $this->packages[$package->getName()];
        } elseif (isset($this->packages[$package->getPrettyName()])) {
            return $this->packages[$package->getPrettyName()];
        } elseif (isset($this->types[$package->getType()])) {
            return $this->types[$package->getType()];
        }
    }
599239
public function processPackage(PackageInterface $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        if ($package->getType() !== self::PACKAGE_TYPE && is_null($files)) {
            return;
        }

        $extension = [
            'name'    => $package->getName(),
            'version' => $package->getVersion(),
        ];
        if ($package->getVersion() === '9999999-dev') {
            $reference = $package->getSourceReference() ?: $package->getDistReference();
            if ($reference) {
                $extension['reference'] = $reference;
            }
        }
        $this->data['extensions'][$package->getName()] = $extension;

        $aliases = array_merge(
            $this->prepareAliases($package, 'psr-0'),
            $this->prepareAliases($package, 'psr-4')
        );
        $this->data['aliases'] = array_merge($this->data['aliases'], $aliases);
        foreach ((array) $files as $name => $path) {
            $config = $this->readExtensionConfig($package, $path);
            $config['aliases'] = array_merge(
                $aliases,
                isset($config['aliases']) ? (array) $config['aliases'] : []
            );
            $this->data['aliases'] = array_merge($this->data['aliases'], $config['aliases']);
            $this->data[$name] = isset($this->data[$name]) ? Helper::mergeConfig($this->data[$name], $config) : $config;
        }
    }
739806
protected function deleteIgnoredFiles(PackageInterface $package)
    {
        $manager = IgnoreFactory::create($this->config, $this->composer, $package, $this->getInstallPath($package));

        if ($manager->isEnabled() && !$manager->hasPattern()) {
            $this->addIgnorePatterns($manager, $package);
        }

        $manager->cleanup();
    }
921801
public function dropNewFiles(PackageInterface $package){

    //Gather all information for dropin directives
    $info = array();

    //Composer doesn't care about uppercase and so shouldn't we
    $info['package'] = strtolower($package->getName());
    $info['vendor'] = substr($info['package'], 0, strpos($info['package'], '/'));
    $info['type'] = $package->getType();

    #Locate absolute urls
    $projectDir = getcwd();

    #Get directives from composer.json
    $extra = $this->composer->getPackage()->getExtra();

    if (isset($extra['dropin-paths'])) {
      $paths = self::getPaths($extra['dropin-paths']);
    } else {
      //Stop here if dropin-paths is not defined.
      return;
    }

    $dest = self::installPath($info);

    //If dropin has nothing to do with this package just end it now
    if (!$dest) {
      return;
    }else {
      $dest = "{$projectDir}/{$dest}"; //Update to full path
    }

    //Compatibility with composer/installers
    if (class_exists('\\Composer\\Installers\\Installer')) {
      $installer = new Installer($this->io,$this->composer);
    } else {
      //System default
      $installer = new LibraryInstaller($this->io,$this->composer);
    }

    try {
      $src = realpath($installer->getInstallPath($package));
    } catch (\InvalidArgumentException $e) {
      // We will end up here if composer/installers doesn't recognise the type
      // In this case it's the default installation folder in vendor
      $vendorDir = $this->composer->getConfig()->get('vendor-dir');
      $vendorDir = realpath($vendorDir);
      $src = "{$vendorDir}/{$info['package']}";
    }

    $config = $this->composer->getPackage()->getConfig();
    $shouldCopy = isset($config['dropin-installer']) && $config['dropin-installer'] === 'copy';

    $installFiles = self::getFilesToInstall($info);
    if ($shouldCopy) {
      $this->io->write("    Copying dropin files...\n");
      if ($installFiles == "*") {
        self::rcopy($src, $dest);
      } else {
        foreach ($installFiles as $file) {
          self::copy("{$src}/{$file}", $dest);
        }
      }
    } else {
      $this->io->write("    Moving dropin files...\n");
      if ($installFiles == "*") {
        self::rmove($src, $dest);
      } else {
        foreach ($installFiles as $file) {
          self::move("{$src}/{$file}", $dest);
        }
      }
    }
  }
275675
private function isInstalledGlobally($package)
    {
        if (!isset($this->globalList)) {
            $this->globalList = $this->shell->execute(
                ['npm', 'ls', '--global', '--no-progress', '--depth=0']
            );
        }

        return $this->globalList && strpos($this->globalList, $package . '@') !== false;
    }
1167276
public function getLoaderFilePackagePath(PackageInterface $package)
    {
        $installPath = $this->getInstallPath($package);

        if ($installPath === false) {
            return false;
        }

        $config      = $this->getInstallerConfig($package);
        $packagePath = $installPath . $config['loader'];

        return $packagePath;
    }
890536
protected function loadInits(PackageInterface $package)
    {
        if (!$package->getInits()) {
            return $this;
        }

        $initLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\InitLoader::class);
        $initLoader->load($package->getInits());
        return $this;
    }