Skip to content

Commit 71cc743

Browse files
Make converter param name case insensitive (#43)
1 parent 70fc9ff commit 71cc743

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/ConvertApi/Task.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ function run()
3131
}
3232

3333
$fromFormat = $this->fromFormat ?: $this->detectFormat($params);
34-
$converter = isset($params['converter']) ? "/converter/{$params['converter']}" : '';
35-
$path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converter;
34+
$converter = $this->detectConverter($params);
35+
$converterPath = $converter ? "/converter/{$converter}" : '';
36+
$path = 'convert/' . $fromFormat . '/to/' . $this->toFormat . $converterPath;
3637

3738
$response = ConvertApi::client()->post($path, $params, $readTimeout);
3839

@@ -91,4 +92,15 @@ private function detectFormat($params)
9192

9293
return $detector->run();
9394
}
95+
96+
private function detectConverter($params)
97+
{
98+
$keys = array_keys($params);
99+
100+
foreach ($keys as $key)
101+
if (strtolower($key) == 'converter')
102+
return $params[$key];
103+
104+
return;
105+
}
94106
}

0 commit comments

Comments
 (0)