Skip to content

Commit dcf562a

Browse files
committed
Allow CURL constant names
1 parent f56531b commit dcf562a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ClientFactory/CurlFactory.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public function createClient(array $config = [])
4040
throw new \LogicException('To use the Curl client you need to install the "php-http/curl-client" package.');
4141
}
4242

43+
// Try to resolve curl constant names
44+
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;
51+
}
52+
}
53+
}
54+
4355
return new Client($this->messageFactory, $this->streamFactory, $config);
4456
}
4557
}

0 commit comments

Comments
 (0)