syokuhou/src/SyokuhouInfo.php
2023-10-20 21:21:17 +00:00

46 lines
1.1 KiB
PHP

<?php
// SyokuhouInfo.php
// Created: 2023-10-20
// Updated: 2023-10-20
namespace Syokuhou;
use UnexpectedValueException;
use Index\Version;
/**
* Retrieves library info.
*/
final class SyokuhouInfo {
private static ?string $versionString = null;
private static ?Version $version = null;
/**
* Returns the current version of the library.
*
* @return Version
*/
public static function getVersion(): Version {
if(self::$version === null)
self::$version = Version::parse(self::getVersionString());
return self::$version;
}
/**
* Returns the current version of the library as a string.
*
* @return string
*/
public static function getVersionString(): string {
if(self::$versionString === null) {
$body = file_get_contents(__DIR__ . '/../VERSION');
if($body === false)
throw new UnexpectedValueException('Was unable to read VERSION file.');
self::$versionString = trim($body);
}
return self::$versionString;
}
}