Skip to content

Commit f3c283d

Browse files
committed
CurlFactory: Add compatibility with curl-client v2
The curl-client rely on PSR17 factories, we must use those factories in the client.
1 parent bad3276 commit f3c283d

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/ClientFactory/CurlFactory.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
namespace Http\HttplugBundle\ClientFactory;
44

55
use Http\Client\Curl\Client;
6-
use Http\Message\MessageFactory;
7-
use Http\Message\StreamFactory;
6+
use Psr\Http\Message\ResponseFactoryInterface;
7+
use Psr\Http\Message\StreamFactoryInterface;
88

99
/**
1010
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1111
*/
1212
class CurlFactory implements ClientFactory
1313
{
1414
/**
15-
* @var MessageFactory
15+
* @var ResponseFactoryInterface
1616
*/
17-
private $messageFactory;
17+
private $responseFactory;
1818

1919
/**
20-
* @var StreamFactory
20+
* @var StreamFactoryInterface
2121
*/
2222
private $streamFactory;
2323

2424
/**
25-
* @param MessageFactory $messageFactory
26-
* @param StreamFactory $streamFactory
25+
* @param ResponseFactoryInterface $responseFactory
26+
* @param StreamFactoryInterface $streamFactory
2727
*/
28-
public function __construct(MessageFactory $messageFactory, StreamFactory $streamFactory)
28+
public function __construct(ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory)
2929
{
30-
$this->messageFactory = $messageFactory;
30+
$this->responseFactory = $responseFactory;
3131
$this->streamFactory = $streamFactory;
3232
}
3333

@@ -53,6 +53,6 @@ public function createClient(array $config = [])
5353
}
5454
}
5555

56-
return new Client($this->messageFactory, $this->streamFactory, $config);
56+
return new Client($this->responseFactory, $this->streamFactory, $config);
5757
}
5858
}

tests/Unit/ClientFactory/CurlFactoryTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Http\Message\MessageFactory;
88
use Http\Message\StreamFactory;
99
use PHPUnit\Framework\TestCase;
10+
use Psr\Http\Message\ResponseFactoryInterface;
11+
use Psr\Http\Message\StreamFactoryInterface;
1012

1113
/**
1214
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -20,8 +22,8 @@ public function testCreateClient()
2022
}
2123

2224
$factory = new CurlFactory(
23-
$this->getMockBuilder(MessageFactory::class)->getMock(),
24-
$this->getMockBuilder(StreamFactory::class)->getMock()
25+
$this->getMockBuilder(ResponseFactoryInterface::class)->getMock(),
26+
$this->getMockBuilder(StreamFactoryInterface::class)->getMock()
2527
);
2628
$client = $factory->createClient();
2729

0 commit comments

Comments
 (0)