/** * {@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; }
/** * {@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; }
/** * Test for get() when nothing is set. */ public function testGetNull() { $holder = new KeyBag(); $this->assertNull($holder->get('ns', 'test')); }