Skip to content

Commit ec6e78a

Browse files
Fixes
1 parent 1e53739 commit ec6e78a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

spec/FlexibleHttpClientSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public function it_is_an_async_http_client()
3232
$this->shouldImplement(HttpAsyncClient::class);
3333
}
3434

35-
public function it_throw_exception_if_invalid_client()
35+
public function it_throw_type_error_if_invalid_client()
3636
{
3737
$this->beConstructedWith(null);
3838

39-
$this->shouldThrow(\LogicException::class)->duringInstantiation();
39+
$this->shouldThrow(\TypeError::class)->duringInstantiation();
4040
}
4141

4242
public function it_emulates_an_async_client(

src/PluginClientFactory.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public static function setFactory(callable $factory)
4747
*/
4848
public function createClient($client, array $plugins = [], array $options = []): PluginClient
4949
{
50+
if (!$client instanceof ClientInterface && !$client instanceof HttpAsyncClient) {
51+
throw new \TypeError(
52+
sprintf('%s::createClient(): Argument #1 ($client) must be of type %s|%s, %s given', self::class, ClientInterface::class, HttpAsyncClient::class, get_debug_type($client))
53+
);
54+
}
55+
5056
if (static::$factory) {
5157
$factory = static::$factory;
5258

0 commit comments

Comments
 (0)