1 | <?php |
||
7 | class DotEnv |
||
8 | { |
||
9 | /** |
||
10 | * Key-value storage. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected static $variables = []; |
||
15 | |||
16 | /** |
||
17 | * Required variables. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $required = []; |
||
22 | |||
23 | /** |
||
24 | * Were variables loaded? |
||
25 | * |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected static $isLoaded = false; |
||
29 | |||
30 | /** |
||
31 | * Load .env.php file or array. |
||
32 | * |
||
33 | * @param string|array $source |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public static function load($source) |
||
44 | |||
45 | /** |
||
46 | * Get env variables. |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | public static function all() |
||
54 | |||
55 | /** |
||
56 | * Get env variable. |
||
57 | * |
||
58 | * @param string $key |
||
59 | * @param mixed $default |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public static function get($key, $default = null) |
||
67 | |||
68 | /** |
||
69 | * Set env variable. |
||
70 | * |
||
71 | * @param string|array $keys |
||
72 | * @param mixed $value |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | public static function set($keys, $value = null) |
||
84 | |||
85 | /** |
||
86 | * Set required variables. |
||
87 | * |
||
88 | * @param array $variables |
||
89 | */ |
||
90 | public static function setRequired(array $variables) |
||
98 | |||
99 | /** |
||
100 | * Delete all variables. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | public static function flush() |
||
109 | |||
110 | /** |
||
111 | * Throw exception if any of required variables was not loaded. |
||
112 | * |
||
113 | * @throws MissingVariableException |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | protected static function checkRequiredVariables() |
||
125 | } |
||
126 |