From eac1d0b16fc1838c97a83b33ad0eb3be673c06f9 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 15 Jan 2017 23:33:54 +0300 Subject: [PATCH] Ref --- src/Metadata.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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