hedera-web/web/version.php

33 lines
726 B
PHP
Raw Normal View History

<?php
namespace Vn\Web;
class Version {
function __construct($version = '') {
if (!empty($version) && preg_match('/^\d+\.\d+\.\d+$/', $version)) {
$numbers = explode('.', $version);
$this->major = (int) $numbers[0];
$this->minor = (int) $numbers[1];
$this->fixes = (int) $numbers[2];
} else {
$this->major = 0;
$this->minor = 0;
$this->fixes = 0;
}
}
function isLowerThan($version) {
if ($this->major == $version->major) {
if ($this->minor == $version->minor)
return $this->fixes < $version->fixes;
else
return $this->minor < $version->minor;
} else
return $this->major < $version->major;
}
function toString() {
return "$this->major.$this->minor.$this->fixes";
}
}