You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
810 B
PHTML
43 lines
810 B
PHTML
6 years ago
|
<?php
|
||
|
|
||
|
namespace Engelsystem\Helpers;
|
||
|
|
||
|
use Engelsystem\Config\Config;
|
||
|
|
||
|
class Version
|
||
|
{
|
||
|
/** @var Config */
|
||
|
protected $config;
|
||
|
|
||
|
/** @vat string */
|
||
|
protected $storage;
|
||
|
|
||
|
/** @var string */
|
||
|
protected $versionFile = 'VERSION';
|
||
|
|
||
|
/**
|
||
|
* @param string $storage
|
||
|
* @param Config $config
|
||
|
*/
|
||
|
public function __construct(string $storage, Config $config)
|
||
|
{
|
||
|
$this->storage = $storage;
|
||
|
$this->config = $config;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getVersion()
|
||
|
{
|
||
|
$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);
|
||
|
}
|
||
|
}
|