Completed
Pull Request — master (#292)
by Carlos
05:19 queued 02:03
created

UserServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
 * UserServiceProvider.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\User\Group;
29
use EasyWeChat\User\User;
30
use Pimple\Container;
31
use Pimple\ServiceProviderInterface;
32
33
/**
34
 * Class UserServiceProvider.
35
 */
36 View Code Duplication
class UserServiceProvider implements ServiceProviderInterface
37
{
38
    /**
39
     * Registers services on the given container.
40
     *
41
     * This method should only be used to configure services and parameters.
42
     * It should not get services.
43
     *
44
     * @param Container $pimple A container instance
45
     */
46
    public function register(Container $pimple)
47
    {
48
        $pimple['user'] = function ($pimple) {
49
           return new User($pimple['access_token']);
50
        };
51
52
        $group = function ($pimple) {
53
           return new Group($pimple['access_token']);
54
        };
55
56
        $pimple['user_group'] = $group;
57
        $pimple['user.group'] = $group;
58
    }
59
}
60