| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Facile\OpenIDClient\Service\Builder; |
| 6 |
|
| 7 |
use Http\Discovery\Psr17FactoryDiscovery; |
| 8 |
use Http\Discovery\Psr18ClientDiscovery; |
| 9 |
use Psr\Http\Client\ClientInterface; |
| 10 |
use Psr\Http\Message\RequestFactoryInterface; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
abstract class AbstractServiceBuilder |
| 16 |
{ |
| 17 |
private ?ClientInterface $httpClient = null; |
| 18 |
|
| 19 |
private ?RequestFactoryInterface $requestFactory = null; |
| 20 |
|
| 21 |
public function setHttpClient(ClientInterface $httpClient): self |
| 22 |
{ |
| 23 |
$this->httpClient = $httpClient; |
| 24 |
|
| 25 |
return $this; |
| 26 |
} |
| 27 |
|
| 28 |
public function setRequestFactory(RequestFactoryInterface $requestFactory): self |
| 29 |
{ |
| 30 |
$this->requestFactory = $requestFactory; |
| 31 |
|
| 32 |
return $this; |
| 33 |
} |
| 34 |
|
| 35 |
protected function getHttpClient(): ClientInterface |
| 36 |
{ |
| 37 |
return $this->httpClient ??= Psr18ClientDiscovery::find(); |
| 38 |
} |
| 39 |
|
| 40 |
protected function getRequestFactory(): RequestFactoryInterface |
| 41 |
{ |
| 42 |
return $this->requestFactory ??= Psr17FactoryDiscovery::findRequestFactory(); |
| 43 |
} |
| 44 |
} |