OAuthServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 17
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace EntWeChat\Foundation\ServiceProviders;
4
5
use EntWeChat\Auth\App;
6
use EntWeChat\Auth\Web;
7
use EntWeChat\Auth\WorkWeb;
8
use Pimple\Container;
9
use Pimple\ServiceProviderInterface;
10
11
/**
12
 * Class OAuthServiceProvider.
13
 */
14
class OAuthServiceProvider implements ServiceProviderInterface
15
{
16
    /**
17
     * Registers services on the given container.
18
     *
19
     * This method should only be used to configure services and parameters.
20
     * It should not get services.
21
     *
22
     * @param Container $pimple A container instance
23
     */
24
    public function register(Container $pimple)
25
    {
26
        $pimple['oauth'] = function ($pimple) {
27
            return new App($pimple['access_token']);
28
        };
29
30
        $pimple['auth'] = function ($pimple) {
31
            return new Web($pimple['access_token']);
32
        };
33
34
        $auth_work = function ($pimple) {
35
            return new WorkWeb($pimple['access_token']);
36
        };
37
38
        $pimple['auth_work'] = $auth_work;
39
        $pimple['auth.work'] = $auth_work;
40
    }
41
}
42