From 069fac9d561c74f0bd6bb96beb7d9d514acb7992 Mon Sep 17 00:00:00 2001 From: Laurynas Butkus Date: Tue, 18 Jul 2023 22:00:58 +0300 Subject: [PATCH] Make converter param name case insensitive --- lib/ConvertApi/Task.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ConvertApi/Task.php b/lib/ConvertApi/Task.php index 6aa07e5..cd9b8d7 100644 --- a/lib/ConvertApi/Task.php +++ b/lib/ConvertApi/Task.php @@ -31,8 +31,9 @@ function run() } $fromFormat = $this->fromFormat ?: $this->detectFormat($params); - $converter = isset($params['converter']) ? "/converter/{$params['converter']}" : ''; - $path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converter; + $converter = $this->detectConverter($params); + $converterPath = $converter ? "/converter/{$converter}" : ''; + $path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converterPath; $response = ConvertApi::client()->post($path, $params, $readTimeout); @@ -91,4 +92,15 @@ private function detectFormat($params) return $detector->run(); } + + private function detectConverter($params) + { + $keys = array_keys($params); + + foreach ($keys as $key) + if (strtolower($key) == 'converter') + return $params[$key]; + + return; + } }