= $target_length) { return $str; } $missing = ( $target_length - strlen($str) ); for($i=0;$i<$target_length;$i++) { $str = "0".$str; } return $str; } /** * Formatiert die Factorio Versionsnummern um zu einem Vergleichbaren Integer. * @param string Factorio Versions Zeichenkette Beispiel: 2.0.14 * @return int zum einfachen Vergleich formatierter Versions-Integer. Beispiel: versionsFormat("2.0.14") -> "000200000014" -> int(200000014) */ private function versionFormat(string $vs) : int { $parts = explode(".", $vs); $new = ""; foreach($parts as $i => $v) { $new .= $this->zero_fill($v, 4); } return intval($new); } public function __construct(string $version) { $this->version = $version; $this->intVersion = $this->versionFormat($version); } public function getVersion() : string { return $this->version; } public function getIntVersion() : int { return $this->intVersion; } public function isNewer(FactorioVersion $other) : bool { return $this->intVersion > $other->getIntVersion(); } public function isOlder(FactorioVersion $other) : bool { return $this->intVersion < $other->getIntVersion(); } }