Skip to content

Commit

Permalink
Allow injection of Guzzle ClientInterface (#118)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jahrsensetence and fschmtt authored Jul 4, 2024
1 parent 715ee40 commit 05c7428
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Keycloak.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Fschmtt\Keycloak\Resource\Users;
use Fschmtt\Keycloak\Serializer\Factory as SerializerFactory;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;

class Keycloak
{
Expand All @@ -34,8 +35,9 @@ public function __construct(
private readonly string $username,
private readonly string $password,
private readonly TokenStorageInterface $tokenStorage = new InMemory(),
?ClientInterface $guzzleClient = new GuzzleClient(),
) {
$this->client = new Client($this, new GuzzleClient(), $this->tokenStorage);
$this->client = new Client($this, $guzzleClient, $this->tokenStorage);
$this->propertyFilter = new PropertyFilter($this->version);
$this->commandExecutor = new CommandExecutor($this->client, $this->propertyFilter);
$this->queryExecutor = new QueryExecutor($this->client, (new SerializerFactory())->create());
Expand Down

0 comments on commit 05c7428

Please sign in to comment.