major = (int)$parts[0]; $v->minor = (int)$parts[1]; $v->patch = (int)$parts[2]; return $v; } function bump(int $up_mode) { if($up_mode == 1) ++$this->patch; else if($up_mode == 2) { ++$this->minor; $this->patch = 0; } else if($up_mode == 3) { ++$this->major; $this->minor = 0; $this->patch = 0; } else throw new Exception("Unsupported up mode: $up_mode"); } function encode() : string { return 'v'.$this->major.'.'.$this->minor.'.'.$this->patch; } }