|
2 | 2 |
|
3 | 3 | namespace Helldar\EnvSync\Services;
|
4 | 4 |
|
| 5 | +use Helldar\EnvSync\Support\Config; |
5 | 6 | use Helldar\Support\Facades\Helpers\Str;
|
6 | 7 |
|
7 | 8 | final class Compiler
|
8 | 9 | {
|
9 |
| - protected $keeping = ['APP_NAME']; |
10 |
| - |
11 |
| - protected $forces = [ |
12 |
| - 'APP_ENV' => 'production', |
13 |
| - 'APP_DEBUG' => false, |
14 |
| - 'APP_URL' => 'http://localhost', |
15 |
| - |
16 |
| - 'LOG_CHANNEL' => 'daily', |
17 |
| - |
18 |
| - 'DB_CONNECTION' => 'mysql', |
19 |
| - 'DB_HOST' => '127.0.0.1', |
20 |
| - 'DB_PORT' => 3306, |
21 |
| - 'DB_DATABASE' => 'default', |
22 |
| - |
23 |
| - 'BROADCAST_DRIVER' => 'redis', |
24 |
| - 'CACHE_DRIVER' => 'redis', |
25 |
| - 'QUEUE_CONNECTION' => 'redis', |
26 |
| - 'SESSION_DRIVER' => 'redis', |
27 |
| - 'SESSION_LIFETIME' => 120, |
28 |
| - |
29 |
| - 'REDIS_HOST' => '127.0.0.1', |
30 |
| - 'REDIS_PORT' => 6379, |
31 |
| - |
32 |
| - 'MAIL_MAILER' => 'smtp', |
33 |
| - 'MAIL_HOST' => 'mailhog', |
34 |
| - 'MAIL_PORT' => 1025, |
35 |
| - ]; |
36 |
| - |
37 | 10 | protected $separator = "\n";
|
38 | 11 |
|
39 | 12 | protected $stringify;
|
40 | 13 |
|
| 14 | + protected $config; |
| 15 | + |
41 | 16 | protected $items;
|
42 | 17 |
|
43 |
| - public function __construct(Stringify $stringify) |
| 18 | + public function __construct(Stringify $stringify, Config $config) |
44 | 19 | {
|
45 | 20 | $this->stringify = $stringify;
|
| 21 | + $this->config = $config; |
46 | 22 | }
|
47 | 23 |
|
48 | 24 | public function items(array $items): self
|
@@ -78,12 +54,12 @@ protected function replace(string $key, $value)
|
78 | 54 |
|
79 | 55 | protected function isKeeping(string $key): bool
|
80 | 56 | {
|
81 |
| - return in_array($key, $this->keeping); |
| 57 | + return in_array($key, $this->config->keep()); |
82 | 58 | }
|
83 | 59 |
|
84 | 60 | protected function value(string $key)
|
85 | 61 | {
|
86 |
| - foreach ($this->forces as $forced_key => $value) { |
| 62 | + foreach ($this->config->forces() as $forced_key => $value) { |
87 | 63 | if (Str::endsWith($key, $forced_key)) {
|
88 | 64 | return $value;
|
89 | 65 | }
|
|
0 commit comments