HttpClientServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: lenovo
5
 * Date: 6/15/2018
6
 * Time: 12:14 AM
7
 */
8
9
namespace TimSDK\Foundation\ServiceProviders;
10
11
use GuzzleHttp\Client;
12
use Pimple\Container;
13
14
class HttpClientServiceProvider extends ServiceProvider
15
{
16
17
    /**
18
     * Registers services on the given container.
19
     *
20
     * This method should only be used to configure services and parameters.
21
     * It should not get services.
22
     *
23
     * @param Container $pimple A container instance
24
     */
25
    public function register(Container $pimple)
26
    {
27
        $pimple['httpClient'] = $pimple[Client::class] = function ($app) {
28
            return new Client(array_merge($app['config']->get('http', []), [
29
                'verify' => realpath($app['path.cert'] . '/cacert.pem')
30
            ]));
31
        };
32
    }
33
}
34