2019-07-21 02:34:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Helpers;
|
|
|
|
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
|
|
|
|
class Version
|
|
|
|
{
|
2022-12-15 19:50:56 +01:00
|
|
|
protected Config $config;
|
2019-07-21 02:34:52 +02:00
|
|
|
|
2022-12-15 19:50:56 +01:00
|
|
|
protected string $storage;
|
2019-07-21 02:34:52 +02:00
|
|
|
|
2022-12-15 19:50:56 +01:00
|
|
|
protected string $versionFile = 'VERSION';
|
2019-07-21 02:34:52 +02:00
|
|
|
|
|
|
|
public function __construct(string $storage, Config $config)
|
|
|
|
{
|
|
|
|
$this->storage = $storage;
|
|
|
|
$this->config = $config;
|
|
|
|
}
|
|
|
|
|
2022-12-14 19:15:20 +01:00
|
|
|
public function getVersion(): string
|
2019-07-21 02:34:52 +02:00
|
|
|
{
|
|
|
|
$file = $this->storage . DIRECTORY_SEPARATOR . $this->versionFile;
|
|
|
|
|
|
|
|
$version = 'n/a';
|
|
|
|
if (file_exists($file)) {
|
|
|
|
$version = trim(file_get_contents($file));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->config->get('version', $version);
|
|
|
|
}
|
|
|
|
}
|