Add version numbers; make app title configurable

This commit is contained in:
Lexi / Zoe 2021-09-23 00:55:05 +02:00
parent 186dcdc0cb
commit 8df2684e5c
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
11 changed files with 159 additions and 38 deletions

42
src/VersionHelper.php Normal file
View file

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace MailAccountAdmin;
class VersionHelper
{
private string $version;
public function __construct()
{
$version = $this->loadFromVersionFile();
if (!empty($version)) {
$this->version = $version;
} elseif ($this->inDevelopmentMode()) {
$this->version = '[dev version]';
} else {
$this->version = '[undefined version]';
}
}
public function getAppVersion(): string
{
return $this->version;
}
private function loadFromVersionFile(): ?string
{
$versionFilePath = __DIR__ . '/../VERSION';
if (file_exists($versionFilePath)) {
$fileContent = file($versionFilePath);
return $fileContent[0] ?? null;
}
return null;
}
private function inDevelopmentMode(): bool
{
return getenv('APP_ENV') === 'development';
}
}