/** * Gets the settings for a given pattern (method calls itself to * get the data from the parent patterns) * * @param string $pattern * @param array $settings * @return array */ public function getSettings($pattern, array $settings = []) { // The pattern has been pre-quoted on generation to speed up the pattern search, // but for this check we need the unquoted version $unquotedPattern = $this->quoter->pregUnQuote($pattern); // Try to get settings for the pattern $addedSettings = $this->getIniPart($unquotedPattern); // set some additional data if (count($settings) === 0) { // The optimization with replaced digits get can now result in setting searches, for which we // won't find a result - so only add the pattern information, is settings have been found. // // If not an empty array will be returned and the calling function can easily check if a pattern // has been found. if (count($addedSettings) > 0) { $settings['browser_name_regex'] = '/^' . $pattern . '$/'; $settings['browser_name_pattern'] = $unquotedPattern; } } // check if parent pattern set, only keep the first one $parentPattern = null; if (isset($addedSettings['Parent'])) { $parentPattern = $addedSettings['Parent']; if (isset($settings['Parent'])) { unset($addedSettings['Parent']); } } // merge settings $settings += $addedSettings; if ($parentPattern !== null) { return $this->getSettings($this->quoter->pregQuote($parentPattern), $settings); } return $settings; }