| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2.0185 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 8 | public static function create($url, $token) |
|
| 25 | { |
||
| 26 | $plugins = [ |
||
| 27 | 8 | new Plugin\RedirectPlugin(), |
|
| 28 | 8 | new Plugin\RetryPlugin(['retries' => 5]), |
|
| 29 | 8 | new Plugin\DecoderPlugin(), |
|
| 30 | 8 | new Plugin\ErrorPlugin(), |
|
| 31 | ]; |
||
| 32 | |||
| 33 | 8 | if ($token) { |
|
| 34 | $plugins[] = new Plugin\AuthenticationPlugin(new QueryParam([ |
||
| 35 | 'api_key' => $token, |
||
| 36 | ])); |
||
| 37 | } |
||
| 38 | |||
| 39 | 8 | $client = new PluginClient(Discovery\HttpClientDiscovery::find(), $plugins); |
|
| 40 | 8 | $streamFactory = Discovery\StreamFactoryDiscovery::find(); |
|
| 41 | 8 | $builder = new MultipartStreamBuilder($streamFactory); |
|
| 42 | |||
| 43 | 8 | return new HttpPlugHttpAdapterClient($client, $url, Discovery\MessageFactoryDiscovery::find(), $builder); |
|
| 44 | } |
||
| 45 | } |
||
| 46 |