summaryrefslogtreecommitdiff
path: root/src/Helpers/Version.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2019-07-21 13:38:05 +0200
committerGitHub <noreply@github.com>2019-07-21 13:38:05 +0200
commit1e16f4c47ec15ffea41e1fa612d205b8db2a16d1 (patch)
tree0d436535bd7094a201e52036acd406f00bfc620f /src/Helpers/Version.php
parent3d8476efd3709806d254b1c41e26e906080e0b39 (diff)
parent4582f808f05205e7a32ecd6ae42dee00295872f1 (diff)
Merge pull request #624 from MyIgel/version
Added version to credits and metrics page
Diffstat (limited to 'src/Helpers/Version.php')
-rw-r--r--src/Helpers/Version.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Helpers/Version.php b/src/Helpers/Version.php
new file mode 100644
index 00000000..97fe6ef3
--- /dev/null
+++ b/src/Helpers/Version.php
@@ -0,0 +1,42 @@
+<?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);
+ }
+}