JsServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 1
1
<?php
2
3
namespace EntWeChat\Foundation\ServiceProviders;
4
5
use EntWeChat\Js\Contact;
6
use EntWeChat\Js\Js;
7
use Pimple\Container;
8
use Pimple\ServiceProviderInterface;
9
10
/**
11
 * Class JsServiceProvider.
12
 */
13
class JsServiceProvider implements ServiceProviderInterface
14
{
15
    /**
16
     * Registers services on the given container.
17
     *
18
     * This method should only be used to configure services and parameters.
19
     * It should not get services.
20
     *
21
     * @param Container $pimple A container instance
22
     */
23
    public function register(Container $pimple)
24
    {
25
        $pimple['js'] = function ($pimple) {
26
            $js = new Js($pimple['access_token']);
27
            $js->setCache($pimple['cache']);
28
29
            return $js;
30
        };
31
32
        $contact = function ($pimple) {
33
            $js = new Contact($pimple['access_token']);
34
            $js->setCache($pimple['cache']);
35
36
            return $js;
37
        };
38
39
        $pimple['js_contact'] = $contact;
40
        $pimple['js.contact'] = $contact;
41
    }
42
}
43