Get a contextual option.

@param string             $option
@param string             $type
@param string|array|null  $original
@param ConnectionKey|null $connectionKey

@return array|Closure|string
547514
protected function getForContext($option, $type, $original, ConnectionKey $connectionKey)
    {
        // Switch context
        switch ($type) {
            case 'servers':
                $contextual = sprintf('connections.%s.servers.%d.config.%s', $connectionKey->name, $connectionKey->server, $option);
                break;

            case 'stages':
                $contextual = sprintf('on.stages.%s.%s', $connectionKey->stage, $option);
                break;

            case 'connections':
                $contextual = sprintf('on.connections.%s.%s', $connectionKey->name, $option);
                break;

            default:
                $contextual = $option;
                break;
        }

        // Merge with defaults
        $value = $this->configuration->get($contextual);
        if (is_array($value) && $original) {
            $value = array_replace($original, $value);
        }

        return $value;
    }
1254706
public function getOptionFromDboptions($option, InputInterface $input)
    {
        $dbOptionReturnValue = null;
        if (!empty($input->getOption('dboptions'))) {
            $dbOptions = explode(',', $input->getOption('dboptions'));
            if (is_array($dbOptions)) {
                foreach ($dbOptions as $dbOption) {
                    $dbOptionParts = explode(':', $dbOption);
                    if (!empty($dbOptionParts[1])) {
                        $dbOptionValue = $dbOptionParts[1];
                    }
                    if ($option === $dbOptionParts[0]) {
                        if (!empty($dbOptionValue)) {
                            $dbOptionReturnValue = $dbOptionValue;
                        } else {
                            $dbOptionReturnValue = true;
                        }
                    }
                }
            }
        }
        return $dbOptionReturnValue;
    }
789165
public function getOption($name = null, $option = null)
    {
        if (is_null($name)) {
            return $this->_option;
        } else {
            $option || $option = $this->getOption();
            if (strpos($name, '.') !== false) {
                list ($key, $name) = explode('.', $name, 2);
                return isset($option[$key]) && is_array($option[$key]) ? $this->getOption($name, $option[$key]) : null;
            } else {
                return isset($option[$name]) ? $option[$name] : null;
            }
        }
    }
1287757
public function getOption($method, $contentType)
    {
        if (isset($this->options[$method])) {
            foreach ($this->options[$method] as $ct) {
                if (strpos($contentType, $ct) !== false) {
                    return $ct;
                }
            }
            return null;
        } else {
            return null;
        }
    }
299177
public function find(string $key): Option
    {
        // Error out if option is not found in schema.
        if (! $this->has($key)) {
            throw UnknownOptionKey::fromKey($key);
        }

        // If we already had instantiated the option, we need to make sure to use the same reference, to keep all
        // consumers in sync.
        if (! $this->identityMap->has($key)) {
            // We don't have an instance in our identity map yet, so we clone one from our schema.
            $option = clone $this->schema[$key];
            $this->identityMap->put($option, $this);
        }
        $option = $this->identityMap->getOption($key);

        // Retrieve the value from persistence, while falling back to the default value if no persisted one was found.
        // Then, cache the value so that we only hit the persistent storage once.
        if (! isset($this->values[$key])) {
            $this->values[$key] = $this->readOption($key, $this->schema[$key]->getValue() ?? null);
        }

        // Keep the value of the option up-to-date with latest changes.
        if (isset($this->values[$key])
            && $option->getValue() !== $this->values[$key]
        ) {
            $option->setValue($this->values[$key], $persist = false);
        }

        return $option;
    }
1215954
public function getOption($option, $defaultValue)
	{
		if (!isset($this->_options[$option]))
		{
			$this->setOption($option, $defaultValue);
		}

		return $this->_options[$option];
	}
260052
public function get($configOption, $fallback = null)
    {
        if (isset($this->configuration[$configOption])) {
            $optionValue = $this->configuration[$configOption];
        } else {
            if (array_key_exists($configOption, $this->configuration)) {
                $optionValue = $fallback;
            }

            try {
                $optionValue = $this->repository->git(sprintf('config --get ' . $configOption));
                $this->configuration[$configOption] = $optionValue;
            } catch (GitRuntimeException $e) {
                $optionValue = $fallback;
                $this->configuration[$configOption] = null;
            }
        }

        return $optionValue;
    }
773713
private function getConnectionOptionsDsn(array $connectionOptions) : string
    {
        $connectionOptionsDsn = '';

        foreach ($connectionOptions as $paramName => $paramValue) {
            $connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue);
        }

        return $connectionOptionsDsn;
    }
768628
public function getConnection($type = null)
    {
        if (is_null($type)) {
            return $this->connection;
        }

        if (!isset($this->connections[CsvDataGateway::class]) && !empty($this->config['dataPath'])) {
            $this->connections[CsvDataGateway::class] = new CsvDataGateway(
                JPATH_ROOT . '/' . $this->config['dataPath']
            );
        }

        if (!isset($this->connections[Connection::class]) && !empty($this->config['databaseUrl'])) {
            $databaseUrl = $this->config['databaseUrl'];
            $url         = parse_url($databaseUrl);

            if ($url['schema'] == 'sqlite') {
                $databaseUrl = str_replace('sqlite://', 'sqlite://' . JPATH_ROOT, $databaseUrl);
            }

            $this->connections[Connection::class] = DriverManager::getConnection(['url' => $databaseUrl]);
        }

        return $this->connections[$type];
    }
1192465
public function getOption($option, $default = null)
    {
        if (in_array($option, $this->availableOptions)) {
            $method = 'get' . ucfirst($option);
            if (method_exists($this, $method)) {
                return $this->$method();
            } elseif (!empty($this->$option)) {
                return $this->$option;
            }

            return $default;
        } else {
            throw new ApiClientException(sprintf('Trying to get unknown option "%s" on %s ', $option, get_class($this)));
        }
    }
979886
public static function getExtension(
        string $type,
        string $default = "unknown"
    ): string
    {
        return array_key_exists($type, self::$types)
            ? self::$types[$type]
            : $default;
    }
744805
public function get(Connection $connection, string $type): ConstraintInterface
    {
        $driver = $connection->driver();

        if (isset($this->instances[$driver][$type])) {
            return $this->instances[$driver][$type];
        }

        return $this->instances[$driver][$type] = $this->createInstance($connection, $type);
    }
488347
protected function getDefaultAddressOption($type, array $options) {
    $default_option = NULL;

    // Check if any address is a default for this type.
    foreach ($options as $option_id => $option) {
      $key = "default-{$type}";
      if (isset($option[$key]) && $option[$key]) {
        $default_option = $option_id;
        break;
      }
    }

    // Fallback to the first option.
    if (!$default_option || !isset($options[$default_option])) {
      $option_ids = array_keys($options);
      $default_option = reset($option_ids);
    }

    return $default_option;
  }
97535
public function get_option( $_key ) {
		$key         = $this->key( $_key, true );
		$version_key = $this->get_version_key( $key );
		$version     = $this->wp_get_option( $version_key, true );
		if ( $this->validate_version( $version, 'option' ) === false ) {
			$this->delete_version_issue( $_key );
			return false;
		}

		return $this->wp_get_option( $key );
	}
1171126
public function getOption($option)
    {
        $this->_setErrorHandler();
        ldap_get_option($this->getConnection(), $option, $returnValue);
        $this->_unsetErrorHandler();

        return $returnValue;
    }
144240
public function getOption($key)
    {
        // If possible use the current record
        $record = $this->Parent();

        if (!$record && $this->Parent()) {
            // Otherwise a singleton of that record
            $record = singleton($this->Parent()->dataClass());
        } elseif (!$record) {
            // Otherwise just use the default options
            $record = singleton(CommentsExtension::class);
        }

        return ($record instanceof CommentsExtension || $record->hasExtension(CommentsExtension::class))
            ? $record->getCommentsOption($key)
            : null;
    }
1141503
public function optionUpdate($type = null)
    {
        if (in_array($type, ['modules', 'languages'])) {
            switch ($type) {
                case 'modules':
                    modules()->updateRegistry();
                    break;

                case 'languages':
                    language()->updateRegistry();
                    break;
            }
        } else {
            modules()->updateRegistry();
            language()->updateRegistry();
        }

        exit(EXIT_SUCCESS);
    }