Пример #1
0
 /**
  * Check if the version must be skipped.
  *
  * @param AssetTypeInterface $assetType The asset type
  * @param string             $name      The composer package name
  * @param string             $version   The version
  *
  * @return bool
  */
 public function skip(AssetTypeInterface $assetType, $name, $version)
 {
     try {
         $cVersion = $assetType->getVersionConverter()->convertVersion($version);
         $normalizedVersion = $this->versionParser->normalize($cVersion);
     } catch (\Exception $ex) {
         return true;
     }
     if (false !== $this->skipByPattern() && $this->forceSkipVersion($normalizedVersion)) {
         return true;
     }
     return $this->doSkip($name, $normalizedVersion);
 }
Пример #2
0
 /**
  * Validates the tag.
  *
  * @param string             $tag
  * @param AssetTypeInterface $assetType
  * @param VersionParser|null $parser
  *
  * @return false|string
  */
 public static function validateTag($tag, AssetTypeInterface $assetType, VersionParser $parser = null)
 {
     if (in_array($tag, array('master', 'trunk', 'default'))) {
         return false;
     }
     if (null === $parser) {
         $parser = new VersionParser();
     }
     try {
         $tag = $assetType->getVersionConverter()->convertVersion($tag);
         $tag = $parser->normalize($tag);
     } catch (\Exception $e) {
         $tag = false;
     }
     return $tag;
 }
 /**
  * Convert the installed package data tests to mock package instance.
  *
  * @param array $installed The config of installed packages
  *
  * @return array The package instance of installed packages
  */
 protected function convertInstalled(array $installed)
 {
     $packages = array();
     $parser = new VersionParser();
     foreach ($installed as $name => $version) {
         $package = $this->getMockBuilder('Composer\\Package\\PackageInterface')->getMock();
         $package->expects($this->any())->method('getName')->will($this->returnValue($name));
         $package->expects($this->any())->method('getVersion')->will($this->returnValue($parser->normalize($version)));
         $package->expects($this->any())->method('getPrettyVersion')->will($this->returnValue($version));
         $packages[] = $package;
     }
     return $packages;
 }