Skip to content

Commit b6f1362

Browse files
committed
Throw exception if not a constant
1 parent dcf562a commit b6f1362

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ClientFactory/CurlFactory.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ public function createClient(array $config = [])
4242

4343
// Try to resolve curl constant names
4444
foreach ($config as $key => $value) {
45-
// If the value starts with 'CURL' we assume it is a reference to a constant.
46-
if (strpos($key, 'CURL') === 0) {
47-
$contantValue = constant($key);
48-
if ($contantValue !== null) {
49-
unset($config[$key]);
50-
$config[$contantValue] = $value;
45+
// If the $key is a string we assume it is a constant
46+
if (is_string($key)) {
47+
if (null === ($constantValue = constant($key))) {
48+
throw new \LogicException(sprintf('Key %s is not an int nor a CURL constant', $key));
5149
}
50+
51+
unset($config[$key]);
52+
$config[$constantValue] = $value;
5253
}
5354
}
5455

0 commit comments

Comments
 (0)