From eddcc2cce2969ea7b8083d244304c74ed5e525e6 Mon Sep 17 00:00:00 2001 From: Zvonimir Maglica Date: Mon, 14 Oct 2019 16:53:24 +0200 Subject: [PATCH] fixed bug on parsing key from url on character API --- src/Model/Character.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Model/Character.php b/src/Model/Character.php index d98a9d6..4084794 100644 --- a/src/Model/Character.php +++ b/src/Model/Character.php @@ -76,9 +76,8 @@ public function getEpisodes($removeDuplicates = false) } /** - * This helper function will extract all URL ids by key. Key can be location, residence or episode - * @param $key - * @param $removeDuplicates + * @param string $key + * @param boolean $removeDuplicates * @return array */ private function extractIdsFromResponseBasedOnKey($key, $removeDuplicates) @@ -86,11 +85,11 @@ private function extractIdsFromResponseBasedOnKey($key, $removeDuplicates) $ids = []; $urls = []; if ($this->info) { - $urls = array_column($this->data['results'], 'location'); + $urls = array_column($this->data['results'], $key); } elseif (isset($this->data[0])) { - $urls = array_column($this->data, 'location'); + $urls = array_column($this->data, $key); } else { - $urls[] = $this->data['location']; + $urls[] = $this->data[$key]; } $urls = array_column($urls, 'url'); if ($removeDuplicates) {