Completed
Push — master ( 2addb1...4d5931 )
by Carlos
08:01 queued 02:29
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 14 3
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\OpenWork\Server;
13
14
use EasyWeChat\Kernel\Encryptor;
15
use EasyWeChat\OpenWork\Server\Handlers\EchoStrHandler;
16
use Pimple\Container;
17
use Pimple\ServiceProviderInterface;
18
19
/**
20
 * ServiceProvider.
21
 *
22
 * @author xiaomin <[email protected]>
23
 */
24
class ServiceProvider implements ServiceProviderInterface
25
{
26
    /**
27
     * {@inheritdoc}.
28
     */
29
    public function register(Container $app)
30
    {
31
        !isset($app['encryptor']) && $app['encryptor'] = function ($app) {
32
            return new Encryptor(
33
                $app['config']['suite_id'],
34
                $app['config']['token'],
35
                $app['config']['aes_key']
36
            );
37
        };
38
39
        !isset($app['server']) && $app['server'] = function ($app) {
40
            $guard = new Guard($app);
41
            $guard->push(new EchoStrHandler($app));
42
            return $guard;
43
        };
44
    }
45
}
46