/
EnvironmentConfig.php
77 lines (67 loc) · 1.64 KB
/
EnvironmentConfig.php
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
<?php
declare(strict_types=1);
namespace Wearesho\Pvbki;
use Horat1us\Environment;
/**
* Class EnvironmentConfig
* @package Wearesho\Pvbki
*/
class EnvironmentConfig extends Environment\Config implements Interrelations\ConfigInterface
{
public function __construct(string $keyPrefix = 'PVBKI_')
{
parent::__construct($keyPrefix);
}
/**
* {@inheritdoc}
*/
public function getUsername(): string
{
return $this->getEnv('USERNAME');
}
/**
* {@inheritdoc}
*/
public function getPassword(): string
{
return $this->getEnv('PASSWORD');
}
/**
* {@inheritdoc}
*/
public function getAccessPoint(): string
{
return $this->getEnv('ACCESS_POINT');
}
/**
* {@inheritdoc}
*/
public function getKey(): string
{
return $this->getEnv('KEY');
}
/**
* {@inheritdoc}
*/
public function getUrl(): string
{
return $this->getEnv('URL', function (): string {
$mode = $this->getMode();
switch ($mode) {
case Interrelations\ConfigInterface::TEST_MODE:
return Interrelations\ConfigInterface::TEST_URL;
case Interrelations\ConfigInterface::PRODUCTION_MODE:
return Interrelations\ConfigInterface::PRODUCTION_URL;
default:
throw new Exceptions\UnsupportedMode($mode);
}
});
}
/**
* {@inheritdoc}
*/
public function getMode(): int
{
return (int)$this->getEnv('MODE', Interrelations\ConfigInterface::PRODUCTION_MODE);
}
}