Completed
Push — master ( 9e0ead...983405 )
by Carlos
11:10 queued 08:26
created

PaymentServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

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
 * PaymentServiceProvider.php.
14
 *
15
 * Part of Overtrue\WeChat.
16
 *
17
 * For the full copyright and license information, please view the LICENSE
18
 * file that was distributed with this source code.
19
 *
20
 * @author    overtrue <[email protected]>
21
 * @copyright 2015
22
 *
23
 * @link      https://github.com/overtrue/wechat
24
 * @link      http://overtrue.me
25
 */
26
namespace EasyWeChat\Foundation\ServiceProviders;
27
28
use EasyWeChat\Payment\LuckyMoney\LuckyMoney;
29
use EasyWeChat\Payment\Merchant;
30
use EasyWeChat\Payment\Payment;
31
use Pimple\Container;
32
use Pimple\ServiceProviderInterface;
33
34
/**
35
 * Class PaymentServiceProvider.
36
 */
37
class PaymentServiceProvider implements ServiceProviderInterface
38
{
39
    /**
40
     * Registers services on the given container.
41
     *
42
     * This method should only be used to configure services and parameters.
43
     * It should not get services.
44
     *
45
     * @param Container $pimple A container instance
46
     */
47
    public function register(Container $pimple)
48
    {
49
        $pimple['merchant'] = function ($pimple) {
50
            $config = array_merge(
51
                    ['app_id' => $pimple['config']['app_id']],
52
                    $pimple['config']->get('payment', [])
53
                );
54
55
            return new Merchant($config);
56
        };
57
58
        $pimple['payment'] = function ($pimple) {
59
           return new Payment($pimple['merchant']);
60
        };
61
62
        $pimple['lucky_money'] = function ($pimple) {
63
            return new LuckyMoney($pimple['merchant']);
64
        };
65
    }
66
}
67