Bolt\Composer\ScriptHandler::getOption PHP Method

getOption() protected static method

Example: With key "dir-mode" it checks for "BOLT_DIR_MODE" environment variable, then "bolt-dir-mode" in composer's extra section, then returns given default value.
protected static getOption ( Composer\Script\Event $event, string $key, mixed $default = null ) : mixed
$event Composer\Script\Event
$key string
$default mixed
return mixed
    protected static function getOption(Event $event, $key, $default = null)
    {
        $key = 'bolt-' . $key;
        if ($value = getenv(strtoupper(str_replace('-', '_', $key)))) {
            return $value;
        }
        $extra = $event->getComposer()->getPackage()->getExtra();
        return isset($extra[$key]) ? $extra[$key] : $default;
    }