-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurlHandleFactory.php
More file actions
35 lines (28 loc) · 1014 Bytes
/
CurlHandleFactory.php
File metadata and controls
35 lines (28 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace MicroDeps\Curl;
use MicroDeps\Curl\Interface\CurlConfigAwareHandleInterface;
use MicroDeps\Curl\Interface\CurlHandleFactoryInterface;
/**
* @phpstan-import-type phpstanCurlOptions from CurlOptionCollection
*/
final class CurlHandleFactory extends AbstractCurlHandleFactory implements CurlHandleFactoryInterface
{
/**
* @param phpstanCurlOptions $options
*/
public function createGetHandle(string $url, array $options = null): CurlConfigAwareHandleInterface
{
if (null !== $options) {
$this->withOptions($options);
}
return new CurlConfigAwareHandle($url, $this->options);
}
public function createPostHandle(string $url, array $postData, array $options = []): CurlConfigAwareHandleInterface
{
$options[CURLOPT_POST] = 1;
$options[CURLOPT_POSTFIELDS] = $postData;
$this->withOptions($options);
return new CurlConfigAwareHandle($url, $this->options);
}
}