示例#1
0
 /**
  * Initializes the version object with a simple version
  * @param  string          $version A simple, single version string
  * @param  bool            $padZero Set empty version pieces to zero?
  * @throws SemVerException
  */
 public function __construct($version, $padZero = false)
 {
     $this->log = new logger();
     $version = (string) $version;
     $expression = sprintf(parent::$dirty_regexp_mask, parent::$global_single_version);
     if (!preg_match($expression, $version, $matches)) {
         $m = 'This is not a valid version';
         $this->log->fatal('Class ' . __CLASS__ . ' | ' . $m . ' ' . $version);
         throw new SemVerException($m, $version);
     }
     parent::matchesToVersionParts($matches, $this->major, $this->minor, $this->patch, $this->build, $this->prtag, $padZero ? 0 : null);
     if ($this->build === '') {
         $this->build = null;
     }
     $this->version = parent::constructVersionFromParts($padZero, $this->major, $this->minor, $this->patch, $this->build, $this->prtag);
     if ($this->major === null) {
         $this->major = -1;
     }
     if ($this->minor === null) {
         $this->minor = -1;
     }
     if ($this->patch === null) {
         $this->patch = -1;
     }
     if ($this->build === null) {
         $this->build = -1;
     }
 }
示例#2
0
 /**
  * Initializes the version object with a simple version
  * @param string $version A simple, single version string
  * @param bool $padZero Set empty version pieces to zero?
  * @throws SemVerException 
  */
 function __construct($version, $padZero = false)
 {
     $version = (string) $version;
     $expression = sprintf(parent::$dirty_regexp_mask, parent::$global_single_version);
     if (!preg_match($expression, $version, $matches)) {
         throw new SemVerException('This is not a valid version');
     }
     parent::matchesToVersionParts($matches, $this->major, $this->minor, $this->patch, $this->build, $this->prtag, $padZero ? 0 : null);
     if ($this->build === '') {
         $this->build = null;
     }
     $this->version = parent::constructVersionFromParts($padZero, $this->major, $this->minor, $this->patch, $this->build, $this->prtag);
     if ($this->major === null) {
         $this->major = -1;
     }
     if ($this->minor === null) {
         $this->minor = -1;
     }
     if ($this->patch === null) {
         $this->patch = -1;
     }
     if ($this->build === null) {
         $this->build = -1;
     }
 }