| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 12 | public static function fromConfig($config): self |
|
| 29 | { |
||
| 30 | 12 | if (is_string($config)) { |
|
| 31 | 6 | return new self(Uri::createFromString($config)); |
|
| 32 | } |
||
| 33 | 9 | if (!isset($config['uri'])) { |
|
| 34 | 3 | throw new \InvalidArgumentException( |
|
| 35 | 3 | '$config argument must be a string or an array containing an "uri" element' |
|
| 36 | ); |
||
| 37 | } |
||
| 38 | 6 | $additionalHeaders = []; |
|
| 39 | 6 | if (isset($config['basic-auth'])) { |
|
| 40 | 6 | $additionalHeaders['Authorization'] = 'Basic ' . \base64_encode($config['basic-auth']); |
|
| 41 | } |
||
| 42 | 6 | return new self(Uri::createFromString($config['uri']), $additionalHeaders); |
|
| 43 | } |
||
| 44 | |||
| 62 |