Parse the defaults if they're a string

@param string|array $defaults Defaults array from the connect() method.
@return string|array
762736
protected static function parseDefaults($defaults)
    {
        if (!is_string($defaults)) {
            return $defaults;
        }

        $regex = '/(?:(?<plugin>[a-zA-Z0-9\/]*)\.)?(?<prefix>[a-zA-Z0-9\/]*?)' .
            '(?:\/)?(?<controller>[a-zA-Z0-9]*):{2}(?<action>[a-zA-Z0-9_]*)/i';

        if (preg_match($regex, $defaults, $matches)) {
            foreach ($matches as $key => $value) {
                // Remove numeric keys and empty values.
                if (is_int($key) || $value === '' || $value === '::') {
                    unset($matches[$key]);
                }
            }
            $length = count($matches);

            if (isset($matches['prefix'])) {
                $matches['prefix'] = strtolower($matches['prefix']);
            }

            if ($length >= 2 || $length <= 4) {
                return $matches;
            }
        }
        throw new RuntimeException("Could not parse `{$defaults}` route destination string.");
    }
299049
protected static function _parseAccept($accept, array $defaults = null)
    {
        if (! empty($accept)) {
            // Get all of the types
            $types = explode(',', $accept);

            foreach ($types as $type) {
                // Split the type into parts
                $parts = explode(';', $type);

                // Make the type only the MIME
                $type = trim(array_shift($parts));

                // Default quality is 1.0
                $options = array('quality' => 1.0);

                foreach ($parts as $part) {
                    // Prevent undefined $value notice below
                    if (strpos($part, '=') === false) {
                        continue;
                    }

                    // Separate the key and value
                    list($key, $value) = explode('=', trim($part));

                    switch ($key) {
                        case 'q':
                            $options['quality'] = (float) trim($value);
                            break;
                        case 'version':
                            $options['version'] = (float) trim($value);
                            break;
                    }
                }

                // Add the accept type and quality
                $defaults[$type] = $options;
            }
        }

        // Make sure that accepts is an array
        $accepts = (array) $defaults;

        // Order by quality
        arsort($accepts);

        return $accepts;
    }
132077
public function getDefaults($args = null)
    {
        if (!is_null($args)) {
            if (is_array($args)) {
                return array_only($this->defaults, $args);
            }
            if (array_key_exists($args, $this->defaults)) {
                return $this->defaults[$args];
            }
        }
        return $this->defaults;
    }
113183
public static function addSettings(array $defaults)
    {
        return [
            'up' => function (Builder $schema) use ($defaults) {
                $settings = new DatabaseSettingsRepository(
                    $schema->getConnection()
                );

                foreach ($defaults as $key => $value) {
                    $settings->set($key, $value);
                }
            },
            'down' => function (Builder $schema) use ($defaults) {
                $settings = new DatabaseSettingsRepository(
                    $schema->getConnection()
                );

                foreach (array_keys($defaults) as $key) {
                    $settings->delete($key);
                }
            }
        ];
    }
282800
public function defaults($key = null)
    {
        if (is_string($key)) {
            if (!$this->has($key)) {
                throw new Exception(sprintf(Exception::STATS_KEY_NOT_EXISTS, $key));
            }

            return $this->defaults->offsetGet($key);
        }

        return $this->defaults->toArray();
    }
1293788
protected function parseKeys($keys)
    {
        return collect($keys)->map(function ($key) {
            if (is_string($key) && Str::startsWith($key, '{') && Str::endsWith($key, '}')) {
                $key = constant(WebDriverKeys::class.'::'.strtoupper(trim($key, '{}')));
            }

            if (is_array($key) && Str::startsWith($key[0], '{')) {
                $key[0] = constant(WebDriverKeys::class.'::'.strtoupper(trim($key[0], '{}')));
            }

            return $key;
        })->all();
    }
209572
private function mergeDefaults($options)
    {
        $defaults = $this->defaults;

        // Case-insensitively merge in default headers if both defaults and
        // options have headers specified.
        if (!empty($defaults['headers']) && !empty($options['headers'])) {
            // Create a set of lowercased keys that are present.
            $lkeys = [];
            foreach (array_keys($options['headers']) as $k) {
                $lkeys[strtolower($k)] = true;
            }
            // Merge in lowercase default keys when not present in above set.
            foreach ($defaults['headers'] as $key => $value) {
                if (!isset($lkeys[strtolower($key)])) {
                    $options['headers'][$key] = $value;
                }
            }
            // No longer need to merge in headers.
            unset($defaults['headers']);
        }

        $result = array_replace_recursive($defaults, $options);
        foreach ($options as $k => $v) {
            if ($v === null) {
                unset($result[$k]);
            }
        }

        return $result;
    }
401183
public static function getDefault($keys, $defaultValue) {
    try {
      $value = self::req($keys);
    } catch (MissingConfigVariableException $e) {
      return $defaultValue;
    }
    
    return $value;
  }
1320725
public static function parse_headers(string $headers): array
    {
        $final_headers = array();
        $list = explode("\n", trim($headers));

        $http = array_shift($list);

        foreach ($list as $header) {
            $parts = explode(':', $header, 2);
            $final_headers[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
        }

        return $final_headers;
    }
503731
public function parse(array $tokens)
    {
        $parser = new Parser($this->symbolContainer);

        if ($this->customGrammarChecker !== null) {
            $parser->setCustomGrammarChecker($this->customGrammarChecker);
        }

        $rootNode = $parser->parse($tokens);

        return $rootNode;
    }
120795
protected function parseEmbeds($embeds)
    {
        if ($embeds === false || $embeds === '') {
            return [];
        } elseif ($embeds === null) {
            return $this->defaultEmbeds;
        }

        if (is_string($embeds)) {
            $embeds = explode(',', $embeds);
        }

        if (is_array($embeds)) {
            $embeds = array_filter(array_map('trim', $embeds));
        } else {
            $embeds = [];
        }

        return $embeds;
    }
835595
protected static function compile_properties(array $properties, $defaults = true)
	{
		$p = $properties;
		$properties = [];

		foreach ($p as $key => $value)
		{
			if (is_int($key))
			{
				$key = $value;
				$value = [];
			}

			// Get property defaults
			if ($defaults and $property = static::property($key, false))
			{
				$value = array_replace_recursive($property, $value);
			}

			$properties[$key] = $value;
		}

		return $properties;
	}
358053
protected static function parseDefaults($doc) {
        $defaults = [];
        foreach (static::parseSection('options:', $doc) as $section) {
            # FIXME corner case "bla: options: --foo"
            list (, $section) = explode(':', $section, 2);
            $splitTmp = array_slice(preg_split("/\n[ \t]*(-\S+?)/", "\n".$section, null, PREG_SPLIT_DELIM_CAPTURE), 1);
            $split = [];
            for ($size=sizeof($splitTmp), $i=0; $i < $size; $i+=2) {
                $split[] = $splitTmp[$i].(isset($splitTmp[$i+1]) ? $splitTmp[$i+1] : '');
            }
            $options = [];
            foreach ($split as $value) {
                if ($value[0] == '-') {
                    $options[] = Option::parse($value);
                }
            }
            $defaults = array_merge($defaults, $options);
        }
        return new \ArrayIterator($defaults);
    }
451356
public function parseHeaders(array $headers)
    {
        $parsed = [];

        foreach ($headers as $key => $val)
        {
            $parsed[] = $key . ': ' . $val;
        }

        return $parsed;
    }
185493
public function strings($strings = null) {
		if (is_array($strings)) {
			return $this->_strings = $this->_strings + $strings;
		}
		if (is_string($strings)) {
			return isset($this->_strings[$strings]) ? $this->_strings[$strings] : null;
		}
		return $this->_strings;
	}
410537
public static function getChildByArray(array $keys, array $values, $default = null) {
		switch (count($keys)) {
			case 0:
				return $values;
			case 1:
				return array_key_exists($keys[0], $values) ? $values[$keys[0]] : $default;
			case 2:
				return isset($values[$keys[0]][$keys[1]]) ? $values[$keys[0]][$keys[1]] : $default;
			case 3:
				return isset($values[$keys[0]][$keys[1]][$keys[2]]) ? $values[$keys[0]][$keys[1]][$keys[2]] : $default;
			case 4:
				return isset($values[$keys[0]][$keys[1]][$keys[2]][$keys[3]]) ? $values[$keys[0]][$keys[1]][$keys[2]][$keys[3]] : $default;
			default:
				return isset($values[$keys[0]]) ? self::getChildByArray(array_slice($keys, 1), $values[$keys[0]], $default) : $default;
		}
	}
1152878
public function addDefaults(array $defaults)
    {
        if ($defaults) {
            foreach ($this->routes as $route) {
                $route->addDefaults($defaults);
            }
        }
    }