/** * {@inheritdoc} */ protected function prepareParsedData(array $matches) { // Remove indexed values $filtered = array_filter(array_keys($matches), 'is_string'); $result = array_intersect_key($matches, array_flip($filtered)); $result = array_filter($result); if (isset($result['time'])) { $result['time'] = $this->formatTime($result['time']); } if (isset($result['response_body_size']) && $result['response_body_size'] == '-') { $result['response_body_size'] = 0; } foreach ($this->keyBag->getNamespaces() as $search) { // Put all variables to single array foreach ($result as $key => $data) { if (strpos($key, "{$search}__") === 0) { $realKey = substr($key, strlen($search) + 2); $realKey = $this->keyBag->get($search, $realKey) ?: $realKey; $result[$search][$realKey] = $data; unset($result[$key]); } } } return $result; }
/** * Test for registerNamespace(). */ public function testRegisterNamespace() { $namespaces = ['ns_1']; $holder = new KeyBag(); $holder->registerNamespace($namespaces[0]); $this->assertEquals($namespaces, $holder->getNamespaces()); }
/** * {@inheritdoc} */ protected function prepareParsedData(array $matches) { $result = parent::prepareParsedData($matches); if (isset($result['time'])) { $result['time'] = $this->formatTime($result['time']); } if (isset($result['response_body_size']) && $result['response_body_size'] == '-') { $result['response_body_size'] = 0; } foreach ($this->keyBag->getNamespaces() as $search) { // Put all variables to single array foreach ($result as $key => $data) { if (strpos($key, "{$search}__") === 0) { $realKey = substr($key, strlen($search) + 2); $realKey = $this->keyBag->get($search, $realKey) ?: $realKey; $result[$search][$realKey] = $data; unset($result[$key]); } } } return $result; }