|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Component\Config; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\Log\LogLevel; |
|
8
|
|
|
|
|
9
|
|
|
final class ConfigProvider implements ConfigProviderInterface |
|
10
|
|
|
{ |
|
11
|
1 |
|
public function getLogFilePath(): string |
|
12
|
|
|
{ |
|
13
|
1 |
|
return $_ENV['LOG_PATH'] ?? ''; |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
1 |
|
public function getJwtSecret(): string |
|
17
|
|
|
{ |
|
18
|
1 |
|
return $_ENV['JWT_SECRET'] ?? ''; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
1 |
|
public function getCookieName(): string |
|
22
|
|
|
{ |
|
23
|
1 |
|
return $_ENV['TOKEN_NAME'] ?? 'nekot'; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
1 |
|
public function getTokenLifetime(): int |
|
27
|
|
|
{ |
|
28
|
1 |
|
return (int) ($_ENV['TOKEN_LIFETIME'] ?? 1086400); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
1 |
|
public function getLogLevel(): string |
|
32
|
|
|
{ |
|
33
|
1 |
|
return $_ENV['LOG_LEVEL'] ?? LogLevel::ERROR; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
1 |
|
public function getCorsOrigin(): string |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $_ENV['CORS_ORIGIN'] ?? ''; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
4 |
|
public function getApiBasePath(): string |
|
42
|
|
|
{ |
|
43
|
4 |
|
return $_ENV['API_BASE_PATH'] ?? ''; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
public function getAssetPath(): string |
|
47
|
|
|
{ |
|
48
|
1 |
|
return $_ENV['ASSET_PATH'] ?? ''; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
3 |
|
public function getBaseUrl(): string |
|
52
|
|
|
{ |
|
53
|
3 |
|
$hostname = $_ENV['HOSTNAME']; |
|
54
|
3 |
|
$port = (int) $_ENV['PORT']; |
|
55
|
3 |
|
$ssl = ((bool) $_ENV['SSL']) === true; |
|
56
|
|
|
|
|
57
|
3 |
|
$protocol = ($ssl === true) |
|
58
|
2 |
|
? 'https' |
|
59
|
1 |
|
: 'http'; |
|
60
|
|
|
|
|
61
|
3 |
|
$port_string = ''; |
|
62
|
|
|
if ( |
|
63
|
3 |
|
$port !== 0 && |
|
64
|
3 |
|
!in_array($port, [80, 443], true) |
|
65
|
|
|
) { |
|
66
|
1 |
|
$port_string = sprintf(':%d', $port); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
3 |
|
return sprintf( |
|
70
|
3 |
|
'%s://%s%s%s', |
|
71
|
|
|
$protocol, |
|
72
|
|
|
$hostname, |
|
73
|
|
|
$port_string, |
|
74
|
3 |
|
$this->getApiBasePath() |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
1 |
|
public function getClientCacheMaxAge(): int |
|
79
|
|
|
{ |
|
80
|
1 |
|
return 86400 * 100; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|