IMCloudServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: lenovo
5
 * Date: 6/14/2018
6
 * Time: 8:58 PM
7
 */
8
9
namespace TimSDK\Core\ServiceProviders;
10
11
use Pimple\Container;
12
use TimSDK\Core\IMCloud;
13
use TimSDK\Core\TLSSig;
14
use TimSDK\Foundation\ServiceProviders\ServiceProvider;
15
16
class IMCloudServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Registers services on the given container.
20
     *
21
     * This method should only be used to configure services and parameters.
22
     * It should not get services.
23
     *
24
     * @param Container $pimple A container instance
25
     */
26
    public function register(Container $pimple)
27
    {
28
        $pimple[IMCloud::class] = $pimple['im'] = function ($app) {
29
            return new IMCloud($app);
30
        };
31
32
        $pimple[TLSSig::class] = $pimple['TLSSig'] = function ($app) {
33
            $api = new TLSSig();
34
            $api->setAppid($app['config']->get('app_id'));
35
            $api->setPrivateKey($app['config']->get('private_key'));
36
            $api->setPublicKey($app['config']->get('public_key'));
37
38
            return $api;
39
        };
40
    }
41
}
42