Lines
100.00%
12 / 12
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 11 / 11 | 100.00% | 1 / 1 | 3 | ||
| client | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 11 | class HibpHttp | |
| 12 | { | |
| 13 | use HibpConfig; | |
| 14 | ||
| 15 | protected ClientInterface $client; | |
| 16 | ||
| 17 | public function __construct(?string $apiKey = null, ?ClientInterface $client = null) | |
| 18 | { | |
| 19 | $headers = [ | |
| 20 | 'User-Agent' => $this->userAgent, | |
| 21 | ]; | |
| 22 | ||
| 23 | if ($apiKey !== null) { | |
| 24 | $headers['hibp-api-key'] = $apiKey; | |
| 25 | } | |
| 26 | ||
| 27 | if ($client !== null) { | |
| 28 | $this->client = $client; | |
| 29 | ||
| 30 | return; | |
| 31 | } | |
| 32 | ||
| 33 | $this->client = new Client([ | |
| 34 | 'headers' => $headers, | |
| 35 | ]); | |
| 36 | } | |
| 37 | ||
| 38 | public function client(): ClientInterface | |
| 39 | { | |
| 40 | return $this->client; | |
| 41 | } | |
| 42 | } |
From Icawebdesign\Hibp\Traits\HibpConfig
| 7 | trait HibpConfig | |
| 8 | { | |
| 9 | protected string $userAgent = 'hibp-php/7'; | |
| 10 | ||
| 11 | protected string $hibpApiRoot = 'https://haveibeenpwned.com/api'; | |
| 12 | ||
| 13 | protected int $apiVersion = 3; | |
| 14 | ||
| 15 | protected string $pwnedPasswordsApiRoot = 'https://api.pwnedpasswords.com'; | |
| 16 | } |