prefix = strtoupper(rtrim($prefix, '_')) . '_'; } /** * @inheritdoc */ public function has($key) { return $this->get($key) !== null; } /** * @inheritdoc */ public function get($key, $defaultFallback = null) { $envKey = $this->prefix . strtoupper(strtr($key, '.-', '__')); $envKey = str_replace($this->prefix . $this->prefix, $this->prefix, $envKey); return getenv($envKey) ?: $defaultFallback; } /** * @inheritdoc */ public function set($key, $value) { throw new \Exception('Cannot call "set" on environmental configuration.'); } /** * @inheritdoc */ public function import($data) { // no-op } /** * @inheritdoc */ public function export() { return []; } /** * @inheritdoc */ public function hasDefault($key) { return false; } /** * @inheritdoc */ public function getDefault($key, $defaultFallback = null) { return $defaultFallback; } /** * @inheritdoc */ public function setDefault($key, $value) { throw new \Exception('Cannot call "setDefault" on environmental configuration.'); } }