load(); return $delimiter ? (new ExtractTopLevelItemsFilter($toLower ? strtolower($prefix) : $prefix, $delimiter))->__invoke($values) : (new RemovePrefixFilter($toLower ? strtolower($prefix) : $prefix))->__invoke($values); } /** * Environment Loader Constructor * * @param string $regex Optionally filter values based on some regex pattern * @param string $delimiter Split variable names on this string into a nested array. (e.g. "MYSQL_HOST" * would become the key, "MYSQL.HOST" (empty string to not delimit) * @param bool $toLower Convert all keys to lower-case */ public function __construct(string $regex = '', string $delimiter = '', bool $toLower = false) { $this->regex = $regex; $this->delimiter = $delimiter; $this->toLower = $toLower; } /** * @return ConfigValues */ public function load(): ConfigValues { $configValues = new Data(); // Make sure we capture *ALL* environment values $envValues = array_merge(getenv(), $_ENV); foreach ($envValues as $valName => $valVal) { if ($this->regex && ! preg_match($this->regex, $valName)) { continue; } $valName = ($this->delimiter) ? str_replace($this->delimiter, '.', $valName) : $valName; $valName = ($this->toLower) ? strtolower($valName) : $valName; $configValues->set($valName, $this->prepareVal((string) $valVal)); } return new ConfigValues($configValues->export()); } /** * Prepare string value * * @param string $value * @return mixed */ private function prepareVal(string $value) { if (is_numeric($value)) { return filter_var($value, FILTER_VALIDATE_INT) !== false ? (int) $value : (float) $value; } switch (strtolower($value)) { case 'null': return null; case 'false': return false; case 'true': return true; default: return $value; } } } __halt_compiler();----SIGNATURE:----UYVatWshUAJg2/kwKcSLs3RN6MWJWTShGzhnk8YTbCva+MePwAvY9u8qNv4SeIfF3fkzOvYlyPKbipzR+D1lVtYYSFg8H5HFQvvmu7ptWd/EJ3gbGU4w6Co+GF/BU4xSY2G42TYJsXncX7gRNQTgMAm91y61eR+I/Z0yCM8yD1d3xySMjSYrWMQkBBDc4kTsSOtz1vwa3ynd2zHlCxWLt8/83knc48iybHT60iq+ZsR/JsCZ882Pw3O3atqUWgXx9OG64rge4ZY0gVhH1m2XIMAXQ6jyIfS/vZw87bAOMfppFz7pB3Czk0dMoPrexuvnxh2diHWxvlOK++A3jbwIYIlicLtuZaPdEi0azezlcpgDLEvIh8+NXGn/3bWOAXC6T5sNmE/U1WH859UcgoFCO/8ao2Uv3zy/FnedYL+zKuPD+V6x3aOoEvh23+gpncfmPdJ6zrlg6RLT+RrV/C7Rb7GPh9QNaRzI28dJeAbIeiTglac9btMKlzcr9A8QGlDhmpY4eaTVH2xGX2r4C+FwJgVY8KmadB3IUtd/ZgA1nwk1Q1HRisCeYD1BTxK9RVbAlgczRLT7S5q0gwP36Anh4Ju3EWjwzQgyk/1I+QxzzR98AeAk9G9YqRAjFxplymEmhf/2HjNeOpLc4mM36577/WiC628XMtGoUDDASI6fN5M=----ATTACHMENT:----OTg1MjE4NzA3NDU1MzQwNiAxODU3MDUzNjU5NjkyNzU0IDQzMDQ4MzI1NzAwOTA3NDA=