Ejemplo n.º 1
0
 /**
  * Version constructor.
  *
  * @param string $version
  * @param int|bool $compliance Compliance level, or just false for loose
  * @throws SemverException in case of any parsing failures
  */
 public function __construct($version = self::DEFAULT_SEMVER, $compliance = self::COMPLIANCE_SEMVER2)
 {
     $version = (string) $version;
     $this->originalString = $version;
     if (!($parsed = VersionParser::parse($version, $issues))) {
         throw end($issues);
     }
     if ($compliance != ($this->compliance = $parsed[VersionParser::COMPLIANCE]) && $compliance) {
         throw SemverException::format('Version "%s" is not of required compliance level', $version);
     }
     $this->version = new NumbersSegment($parsed[VersionParser::VERSION]);
     $this->prerelease = new PrereleaseSegment($parsed[VersionParser::PRERELEASE]);
     $this->build = new IdentifierSegment($parsed[VersionParser::BUILD]);
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \Omines\Semver\Exception\SemverException
  * @expectedExceptionMessage Semver string "1.2.3.4" contains 4 version numbers, should be 3 at most
  */
 public function testTooLongSemver2Exception()
 {
     VersionParser::parseSemver2('1.2.3.4');
 }