Skip to content

Commit 05c7428

Browse files
Allow injection of Guzzle ClientInterface (#118)
* Allow injection of GuzzleClient so that a configured instance (e.g., with verify=false) can be used. * Apply suggestions from code review Works for me. :) Thanks. Co-authored-by: Frederik Schmitt <[email protected]> --------- Co-authored-by: Frederik Schmitt <[email protected]>
1 parent 715ee40 commit 05c7428

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Keycloak.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Fschmtt\Keycloak\Resource\Users;
2121
use Fschmtt\Keycloak\Serializer\Factory as SerializerFactory;
2222
use GuzzleHttp\Client as GuzzleClient;
23+
use GuzzleHttp\ClientInterface;
2324

2425
class Keycloak
2526
{
@@ -34,8 +35,9 @@ public function __construct(
3435
private readonly string $username,
3536
private readonly string $password,
3637
private readonly TokenStorageInterface $tokenStorage = new InMemory(),
38+
?ClientInterface $guzzleClient = new GuzzleClient(),
3739
) {
38-
$this->client = new Client($this, new GuzzleClient(), $this->tokenStorage);
40+
$this->client = new Client($this, $guzzleClient, $this->tokenStorage);
3941
$this->propertyFilter = new PropertyFilter($this->version);
4042
$this->commandExecutor = new CommandExecutor($this->client, $this->propertyFilter);
4143
$this->queryExecutor = new QueryExecutor($this->client, (new SerializerFactory())->create());

0 commit comments

Comments
 (0)