Skip to content

Commit 876d2e5

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 8a66c0e commit 876d2e5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use Http\HttplugBundle\ClientFactory\CurlFactory;
66
use Http\Client\Curl\Client;
7-
use Http\Message\MessageFactory;
8-
use Http\Message\StreamFactory;
97
use PHPUnit\Framework\TestCase;
8+
use Psr\Http\Message\ResponseFactoryInterface;
9+
use Psr\Http\Message\StreamFactoryInterface;
1010

1111
/**
1212
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -20,8 +20,8 @@ public function testCreateClient()
2020
}
2121

2222
$factory = new CurlFactory(
23-
$this->getMockBuilder(MessageFactory::class)->getMock(),
24-
$this->getMockBuilder(StreamFactory::class)->getMock()
23+
$this->getMockBuilder(ResponseFactoryInterface::class)->getMock(),
24+
$this->getMockBuilder(StreamFactoryInterface::class)->getMock()
2525
);
2626
$client = $factory->createClient();
2727

0 commit comments

Comments
 (0)