예제 #1
0
 /**
  * Retrieve the current version available remotely.
  *
  * @param Updater $updater
  * 
  * @return string
  */
 public function getCurrentRemoteVersion(Updater $updater)
 {
     /* Switch remote request errors to HttpRequestExceptions */
     set_error_handler(array($updater, 'throwHttpRequestException'));
     $versions = json_decode(humbug_get_contents(self::MANIFEST), true);
     restore_error_handler();
     if (false === $versions) {
         throw new HttpRequestException(sprintf('Request to URL failed: %s', self::MANIFEST));
     }
     $versionParser = new VersionParser($versions);
     if ($this->getStability() === self::STABLE) {
         return $versionParser->getMostRecentStable();
     }
     if ($this->getStability() === self::UNSTABLE) {
         return $versionParser->getMostRecentUnstable();
     }
     return $versionParser->getMostRecentAll();
 }
예제 #2
0
 /**
  * Retrieve the current version available remotely.
  *
  * @param Updater $updater
  * @return string|bool
  */
 public function getCurrentRemoteVersion(Updater $updater)
 {
     /** Switch remote request errors to HttpRequestExceptions */
     set_error_handler(array($updater, 'throwHttpRequestException'));
     $packageUrl = $this->getApiUrl();
     $package = json_decode(humbug_get_contents($packageUrl), true);
     restore_error_handler();
     if (null === $package || json_last_error() !== JSON_ERROR_NONE) {
         throw new JsonParsingException('Error parsing JSON package data' . (function_exists('json_last_error_msg') ? ': ' . json_last_error_msg() : ''));
     }
     $versions = array_keys($package['package']['versions']);
     $versionParser = new VersionParser($versions);
     if ($this->getStability() === self::STABLE) {
         $this->remoteVersion = $versionParser->getMostRecentStable();
     } elseif ($this->getStability() === self::UNSTABLE) {
         $this->remoteVersion = $versionParser->getMostRecentUnstable();
     } else {
         $this->remoteVersion = $versionParser->getMostRecentAll();
     }
     /**
      * Setup remote URL if there's an actual version to download
      */
     if (!empty($this->remoteVersion)) {
         $this->remoteUrl = $this->getDownloadUrl($package);
     }
     return $this->remoteVersion;
 }
예제 #3
0
 public function testShouldSelectMostRecentUnstableFromVaryingNumeralCounts()
 {
     $versions = array('1.0-dev', '1.0.0-alpha1');
     $parser = new VersionParser($versions);
     $this->assertSame('1.0.0-alpha1', $parser->getMostRecentUnstable());
 }