| Total Complexity | 6 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class VivaPaymentsServiceProvider extends ServiceProvider |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Register the application services. |
||
| 12 | * |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public function register() |
||
| 16 | { |
||
| 17 | $this->mergeConfigFrom( |
||
| 18 | __DIR__.'/../config/services.php', |
||
| 19 | 'services' |
||
| 20 | ); |
||
| 21 | |||
| 22 | $this->app->singleton(Client::class, function ($app) { |
||
| 23 | return new Client( |
||
| 24 | $this->buildGuzzleClient(), |
||
| 25 | $app->make('config')->get('services.viva.environment') |
||
| 26 | ); |
||
| 27 | }); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Build the Guzzlehttp client. |
||
| 32 | */ |
||
| 33 | protected function buildGuzzleClient(): GuzzleClient |
||
| 34 | { |
||
| 35 | return new GuzzleClient([ |
||
| 36 | 'curl' => $this->curlDoesntUseNss() |
||
| 37 | ? [CURLOPT_SSL_CIPHER_LIST => 'TLSv1'] |
||
| 38 | : [], |
||
| 39 | ]); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Check if cURL doens't use NSS. |
||
| 44 | * |
||
| 45 | * @return bool |
||
| 46 | */ |
||
| 47 | protected function curlDoesntUseNss() |
||
| 48 | { |
||
| 49 | $curl = curl_version(); |
||
| 50 | |||
| 51 | return ! preg_match('/NSS/', $curl['ssl_version']); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Determine if the provider is deferred. |
||
| 56 | * |
||
| 57 | * @return bool |
||
| 58 | */ |
||
| 59 | public function isDeferred() |
||
| 60 | { |
||
| 61 | return true; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get the services provided by the provider. |
||
| 66 | * |
||
| 67 | * @return array |
||
| 68 | */ |
||
| 69 | public function provides() |
||
| 72 | } |
||
| 73 | } |
||
| 74 |