Пример #1
0
 /**
  * Returns the components of the string representation.
  *
  * @param string $version The string representation.
  *
  * @return array The components of the version.
  *
  * @throws InvalidStringRepresentationException If the string representation
  *                                              is invalid.
  */
 public static function toComponents($version)
 {
     if (!Validator::isVersion($version)) {
         throw new InvalidStringRepresentationException($version);
     }
     if (false !== strpos($version, '+')) {
         list($version, $build) = explode('+', $version);
         $build = explode('.', $build);
     }
     if (false !== strpos($version, '-')) {
         list($version, $pre) = explode('-', $version);
         $pre = explode('.', $pre);
     }
     list($major, $minor, $patch) = explode('.', $version);
     return array(self::MAJOR => intval($major), self::MINOR => intval($minor), self::PATCH => intval($patch), self::PRE_RELEASE => isset($pre) ? $pre : array(), self::BUILD => isset($build) ? $build : array());
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     return '' != \Phar::running(false) && Version\Validator::isVersion($this->getApplication()->getVersion());
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function getReleases()
 {
     $response = $this->client->apiRepository()->tags($this->getUsername(), $this->getRepository());
     $resultArray = json_decode($response->getContent(), true);
     $releases = [];
     foreach ($resultArray as $name => $release) {
         $version = ltrim($name, 'v');
         $releases[] = ['url' => sprintf('%s/%s/%s/commits/tag/%s', $this->domain, $this->getUsername(), $this->getRepository(), $name), 'id' => null, 'name' => $name, 'tag_name' => $name, 'body' => $release['message'], 'draft' => false, 'prerelease' => VersionValidator::isVersion($version) && !Parser::toVersion($version)->isStable(), 'created_at' => new \DateTime($release['utctimestamp']), 'updated_at' => null, 'published_at' => new \DateTime($release['utctimestamp']), 'user' => $release['author']];
     }
     return $releases;
 }
Пример #4
0
 /**
  * Sets the pre-release version identifiers.
  *
  * @param array $identifiers The pre-release version identifiers.
  *
  * @return Builder The Version builder.
  *
  * @throws InvalidIdentifierException If an identifier is invalid.
  */
 public function setPreRelease(array $identifiers)
 {
     foreach ($identifiers as $identifier) {
         if (!Validator::isIdentifier($identifier)) {
             throw new InvalidIdentifierException($identifier);
         }
     }
     $this->preRelease = $identifiers;
     return $this;
 }
 /**
  * @dataProvider getValidVersions
  */
 public function testIsVersionValid($version)
 {
     $this->assertTrue(Validator::isVersion($version));
 }