| Conditions | 4 |
| Paths | 4 |
| Total Lines | 20 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4.25 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 3 | public static function make($handler) |
|
| 20 | { |
||
| 21 | //No handler specified |
||
| 22 | 3 | if (!$handler) { |
|
| 23 | return new DropboxGuzzleHttpClient(); |
||
| 24 | } |
||
| 25 | |||
| 26 | //Custom Implementation, maybe. |
||
| 27 | 3 | if ($handler instanceof DropboxHttpClientInterface) { |
|
| 28 | 3 | return $handler; |
|
| 29 | } |
||
| 30 | |||
| 31 | //Handler is a custom configured Guzzle Client |
||
| 32 | 3 | if ($handler instanceof Guzzle) { |
|
| 33 | 3 | return new DropboxGuzzleHttpClient($handler); |
|
| 34 | } |
||
| 35 | |||
| 36 | //Invalid handler |
||
| 37 | throw new InvalidArgumentException('The http client handler must be an instance of GuzzleHttp\Client or an instance of Kunnu\Dropbox\Http\Clients\DropboxHttpClientInterface.'); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |