diff --git a/src/Metadata.php b/src/Metadata.php index fc0ef7e..979b719 100644 --- a/src/Metadata.php +++ b/src/Metadata.php @@ -47,14 +47,10 @@ public function fetch( callable $valueCallback = null ) { $output = []; + $decoded = $input->getDecoded(); foreach ($keys as $key) { - $fetched = $this->utils->fetchKeys( - $input->getDecoded(), - $this->config->getAliases($key) - ); - - foreach ($fetched as $name => $value) { + foreach ($this->getKeyValues($decoded, $key) as $name => $value) { //Get first not-empty value. if (!empty($value)) { if (!empty($keyCallback)) { @@ -74,4 +70,14 @@ public function fetch( return $output; } + + /** + * @param array $data + * @param string $key + * @return array + */ + protected function getKeyValues(array $data, $key) + { + return $this->utils->fetchKeys($data, $this->config->getAliases($key)); + } } \ No newline at end of file