-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApiConfig.php
More file actions
81 lines (67 loc) · 1.74 KB
/
ApiConfig.php
File metadata and controls
81 lines (67 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace App\Helpers;
use Nette;
use Nette\Utils\Arrays;
/**
* Holder of configuration API item, which should describe this server.
*/
class ApiConfig
{
use Nette\SmartObject;
/**
* Address of API server as visible from outside world.
* @var string
*/
protected $address;
/**
* Some basic name which should be used for identification of service
* @var string
*/
protected $name;
/**
* Basic description of this server.
* @var string
*/
protected $description;
/**
* Version of the project in semantic versioning (major.minor.patch)
* @var string
*/
protected $version;
/**
* Format in which version will be displayed
* @var string
*/
protected $versionFormat;
/**
* Constructs configuration object from given array.
* @param array $config
*/
public function __construct(array $config)
{
$this->address = Arrays::get($config, ["address"]);
$this->name = Arrays::get($config, ["name"]);
$this->description = Arrays::get($config, ["description"]);
$this->versionFormat = Arrays::get($config, ["versionFormat"], "{tag}");
// version is constructed from git version tag
$versionFile = __DIR__ . "/../../.version";
$version = file_exists($versionFile) ? trim(@file_get_contents($versionFile)) : null;
$this->version = $version ?: "UNKNOWN";
}
public function getAddress()
{
return $this->address;
}
public function getName()
{
return $this->name;
}
public function getDescription()
{
return $this->description;
}
public function getVersion()
{
return $this->version;
}
}