/**
* Gets the relevant part (array of settings) of the ini file for a given pattern.
*
* @param string $pattern
* @return array
*/
private function getIniPart($pattern)
{
$pattern = strtolower($pattern);
$patternhash = Pattern::getHashForParts($pattern);
$subkey = SubKey::getIniPartCacheSubKey($patternhash);
if (!$this->cache->hasItem('browscap.iniparts.' . $subkey, true)) {
$this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" not found');
return [];
}
$success = null;
$file = $this->cache->getItem('browscap.iniparts.' . $subkey, true, $success);
if (!$success) {
$this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" not found');
return [];
}
if (!is_array($file) || !count($file)) {
$this->logger->debug('cache key "browscap.iniparts.' . $subkey . '" was empty');
return [];
}
$propertyFormatter = new PropertyFormatter(new PropertyHolder());
$return = [];
foreach ($file as $buffer) {
list($tmpBuffer, $patterns) = explode("\t", $buffer, 2);
if ($tmpBuffer === $patternhash) {
$return = json_decode($patterns, true);
foreach (array_keys($return) as $property) {
$return[$property] = $propertyFormatter->formatPropertyValue($return[$property], $property);
}
break;
}
}
return $return;
}