Completed
Push — master ( 6971e7...8d77a8 )
by Carlos
06:30 queued 02:09
created

MiniProgramServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 1
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 1
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
/**
13
 * MiniProgramServiceProvider.php.
14
 *
15
 * This file is part of the wechat.
16
 *
17
 * (c) mingyoung <[email protected]>
18
 *
19
 * This source file is subject to the MIT license that is bundled
20
 * with this source code in the file LICENSE.
21
 */
22
23
namespace EasyWeChat\Foundation\ServiceProviders;
24
25
use EasyWeChat\MiniProgram\AccessToken;
26
use EasyWeChat\MiniProgram\MiniProgram;
27
use Pimple\Container;
28
use Pimple\ServiceProviderInterface;
29
30
/**
31
 * Class MiniProgramServiceProvider.
32
 */
33
class MiniProgramServiceProvider implements ServiceProviderInterface
34
{
35
    /**
36
     * Registers services on the given container.
37
     *
38
     * This method should only be used to configure services and parameters.
39
     * It should not get services.
40
     *
41
     * @param Container $pimple A container instance
42
     */
43
    public function register(Container $pimple)
44
    {
45
        $pimple['mini_program_access_token'] = function ($pimple) {
46
            $config = $pimple['config']->get('mini_program');
47
48
            return new AccessToken(
49
                $config['app_id'],
50
                $config['secret'],
51
                $pimple['cache']
52
            );
53
        };
54
55
        $pimple['mini_program'] = function ($pimple) {
56
            return new MiniProgram(
57
                $pimple['mini_program_access_token'],
58
                $pimple['config']->get('mini_program')
59
            );
60
        };
61
    }
62
}
63