-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathEnv.php
More file actions
60 lines (50 loc) · 1.68 KB
/
Copy pathEnv.php
File metadata and controls
60 lines (50 loc) · 1.68 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
<?php
/*
* Copyright (c) Default Value LLC.
* This source file is subject to the License https://github.com/DefaultValue/dockerizer_for_php/LICENSE.txt
* Do not change this file if you want to upgrade the tool to the newer versions in the future
* Please, contact us at https://default-value.com/#contact if you wish to customize this tool
* according to you business needs
*/
declare(strict_types=1);
namespace DefaultValue\Dockerizer\Shell;
// @TODO: validate files and dirs on startup
class Env
{
public const ENV_PROJECTS_ROOT_DIR = 'DOCKERIZER_PROJECTS_ROOT_DIR';
private const ENV_SSL_CERTIFICATES_DIR = 'DOCKERIZER_SSL_CERTIFICATES_DIR';
private const ENV_TRAEFIK_SSL_CONFIGURATION_FILE = 'DOCKERIZER_TRAEFIK_SSL_CONFIGURATION_FILE';
/**
* @return string
*/
public function getProjectsRootDir(): string
{
return realpath($this->getEnv(self::ENV_PROJECTS_ROOT_DIR)) . DIRECTORY_SEPARATOR;
}
/**
* @return string
*/
public function getSslCertificatesDir(): string
{
return realpath($this->getEnv(self::ENV_SSL_CERTIFICATES_DIR)) . DIRECTORY_SEPARATOR;
}
/**
* @return string
*/
public function getTraefikSslConfigurationFile(): string
{
return $this->getEnv(self::ENV_TRAEFIK_SSL_CONFIGURATION_FILE);
}
/**
* @param string $variable
* @return string
*/
public function getEnv(string $variable): string
{
$envVariableValue = getenv($variable);
if ($envVariableValue === false) {
throw new EnvironmentVariableMissedException("Environment variable $variable is not available");
}
return $envVariableValue;
}
}