Passed
Push — master ( 5621d4...3d9624 )
by mingyoung
02:21
created

ServiceProvider::register()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 1
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the mingyoung/dingtalk.
5
 *
6
 * (c) 张铭阳 <[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 EasyDingTalk\Auth;
13
14
use Pimple\Container;
15
use Pimple\ServiceProviderInterface;
16
use Symfony\Component\HttpFoundation\Session\Session;
17
18
class ServiceProvider implements ServiceProviderInterface
19
{
20
    /**
21
     * Registers services on the given container.
22
     * This method should only be used to configure services and parameters.
23
     * It should not get services.
24
     *
25
     * @param \Pimple\Container $pimple A container instance
26
     */
27
    public function register(Container $pimple)
28
    {
29
        $pimple['sso'] = function ($app) {
30
            return new SsoClient($app);
31
        };
32
33
        $pimple['oauth'] = function ($app) {
34
            if (!$app['request']->hasSession()) {
35
                $app['request']->setSession(new Session());
36
            }
37
38
            return new OAuthClient($app);
39
        };
40
    }
41
}
42