Completed
Pull Request — master (#1275)
by
unknown
03:05
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 keacefull/wechat.
5
 *
6
 * (c) xiaomin <[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
 * Class ServiceProvider
21
 * @package EasyWeChat\OpenWork\Server
22
 *
23
 * @author Xiaomin<[email protected]>
24
 *
25
 */
26
class ServiceProvider implements ServiceProviderInterface
27
{
28
    /**
29
     * {@inheritdoc}.
30
     */
31
    public function register(Container $app)
32
    {
33
        !isset($app['encryptor']) && $app['encryptor'] = function ($app) {
34
            return new Encryptor(
35
                $app['config']['suite_id'],
36
                $app['config']['token'],
37
                $app['config']['aes_key']
38
            );
39
        };
40
41
        !isset($app['server']) && $app['server'] = function ($app) {
42
            $guard = new Guard($app);
43
            $guard->push(new EchoStrHandler($app));
44
            return $guard;
45
        };
46
    }
47
}
48