Ejemplo n.º 1
0
 /**
  * tries to find a token within the name/keywords/description
  *
  * @param  CompletePackageInterface $package
  * @param  string                   $token
  * @return boolean
  */
 private function matchPackage(CompletePackageInterface $package, $token)
 {
     $score = 0;
     if (false !== stripos($package->getName(), $token)) {
         $score += 5;
     }
     if (!$this->onlyName && false !== stripos(join(',', $package->getKeywords() ?: array()), $token)) {
         $score += 3;
     }
     if (!$this->onlyName && false !== stripos($package->getDescription(), $token)) {
         $score += 1;
     }
     return $score;
 }
Ejemplo n.º 2
0
    /**
     * Normalize the alias of branch.
     *
     * @param CompletePackageInterface $package The package instance
     *
     * @return string The alias branch name
     */
    protected function normalizeBranchAlias(CompletePackageInterface $package)
    {
        $stability = VersionParser::parseStability($this->versionParser->normalize($this->rootPackageVersion));
        $aliasNormalized = 'dev-' . $this->rootPackageVersion;

        if (BasePackage::STABILITY_STABLE === BasePackage::$stabilities[$stability]
            && null === $this->findPackage($package->getName(), $this->rootPackageVersion)) {
            $aliasNormalized = $this->versionParser->normalize($this->rootPackageVersion);
        }

        return $aliasNormalized;
    }