1 | <?php |
||
8 | class DotenvEditor |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $env = []; |
||
14 | |||
15 | /** |
||
16 | * @var \sixlive\DotenvEditor\EnvFile |
||
17 | */ |
||
18 | protected $envFile; |
||
19 | |||
20 | /** |
||
21 | * Load an values from an env file. |
||
22 | * |
||
23 | * @param string $path |
||
24 | * @return self |
||
25 | * |
||
26 | * @throws \InvalidArgumentException |
||
27 | */ |
||
28 | 13 | public function load($path) |
|
42 | |||
43 | /** |
||
44 | * Set a key value pair for the env file. |
||
45 | * |
||
46 | * @param string $key |
||
47 | * @param string $value |
||
48 | * @return self |
||
49 | */ |
||
50 | 11 | public function set($key, $value) |
|
56 | |||
57 | /** |
||
58 | * Unset a key value of the env file. |
||
59 | * |
||
60 | * @param string $key |
||
61 | * @return self |
||
62 | */ |
||
63 | 5 | public function unset($key) |
|
69 | |||
70 | /** |
||
71 | * Get all of the env values or a single value by key. |
||
72 | * |
||
73 | * @param string $key |
||
74 | * @return array|string |
||
75 | */ |
||
76 | 5 | public function getEnv($key = '') |
|
82 | |||
83 | /** |
||
84 | * Save the current representation to disk. If no path is specifed and |
||
85 | * a file was loaded, it will overwrite the file that was loaded. |
||
86 | * |
||
87 | * @param string $path |
||
88 | * @return bool |
||
89 | */ |
||
90 | 9 | public function save($path = '') |
|
98 | |||
99 | /** |
||
100 | * Add an empty line to the config. |
||
101 | * @return self |
||
102 | */ |
||
103 | 2 | public function addEmptyLine() |
|
109 | |||
110 | /** |
||
111 | * Add a comment heading. If there is a line before it, it will add an empty |
||
112 | * line before the heading. |
||
113 | * |
||
114 | * @param string $heading |
||
115 | * @return self |
||
116 | */ |
||
117 | 3 | public function heading($heading) |
|
127 | |||
128 | /** |
||
129 | * Check if a key is defined in the env. |
||
130 | * |
||
131 | * @param string $key |
||
132 | * @return bool |
||
133 | */ |
||
134 | 1 | public function has($key) |
|
138 | |||
139 | 16 | public function __destruct() |
|
145 | |||
146 | /** |
||
147 | * Format the config file in key=value pairs. |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 9 | private function format() |
|
161 | } |
||
162 |