1 | <?php |
||
7 | class DotenvEditor |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $env = []; |
||
13 | |||
14 | /** |
||
15 | * @var \sixlive\DotenvEditor\EnvFile |
||
16 | */ |
||
17 | protected $envFile; |
||
18 | |||
19 | /** |
||
20 | * Load an values from an env file. |
||
21 | * |
||
22 | * @param string $path |
||
23 | * |
||
24 | * @return self |
||
25 | */ |
||
26 | 8 | public function load($path) |
|
36 | |||
37 | /** |
||
38 | * Set a key value pair for the env file. |
||
39 | * |
||
40 | * @param string $key |
||
41 | * @param string $value |
||
42 | * |
||
43 | * @return self |
||
44 | */ |
||
45 | 8 | public function set($key, $value) |
|
51 | |||
52 | /** |
||
53 | * Get all of the env values or a single value by key. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * |
||
57 | * @return array|string |
||
58 | */ |
||
59 | 3 | public function getEnv($key = '') |
|
65 | |||
66 | /** |
||
67 | * Save the current representation to disk. If no path is specifed and |
||
68 | * a file was loaded, it will overwrite the file that was loaded. |
||
69 | * |
||
70 | * @param string $path |
||
71 | * |
||
72 | * @return self |
||
73 | */ |
||
74 | 6 | public function save($path = '') |
|
84 | |||
85 | /** |
||
86 | * Add an empty line to the config. |
||
87 | * |
||
88 | * @return self |
||
89 | */ |
||
90 | 2 | public function addEmptyLine() |
|
96 | |||
97 | /** |
||
98 | * Add a comment heading. If there is a line before it, it will add an empty |
||
99 | * line before the heading. |
||
100 | * |
||
101 | * @param string $heading |
||
102 | * |
||
103 | * @return self |
||
104 | */ |
||
105 | 3 | public function heading($heading) |
|
115 | |||
116 | /** |
||
117 | * Check if a key is defined in the env. |
||
118 | * |
||
119 | * @param string $key |
||
120 | * |
||
121 | * @return boolean |
||
122 | */ |
||
123 | 1 | public function has($key) |
|
127 | |||
128 | 10 | public function __destruct() |
|
134 | |||
135 | /** |
||
136 | * Format the config file in key=value pairs. |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | private function format() |
||
150 | } |
||
151 |