From ed533da6d47d0fda08fcc31090686db0090f2cbc Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sat, 6 Jan 2018 18:03:06 +0100 Subject: [PATCH] New environment variable: AUDIO_BITRATE Refactor environment variables code --- classes/Config.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index b49ac44..d662403 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -111,11 +111,23 @@ class Config } } } - if (getenv('CONVERT')) { - $this->convert = (bool) getenv('CONVERT'); - } - if (getenv('PYTHON')) { - $this->python = getenv('PYTHON'); + $this->getEnv(); + } + + /** + * Override options from environement variables. + * Supported environment variables: CONVERT, PYTHON, AUDIO_BITRATE. + * + * @return void + */ + private function getEnv() + { + foreach (['CONVERT', 'PYTHON', 'AUDIO_BITRATE'] as $var) { + $env = getenv($var); + if ($env) { + $prop = lcfirst(str_replace('_', '', ucwords(strtolower($var), '_'))); + $this->$prop = $env; + } } }