Passed
Pull Request — master (#1647)
by
11:06
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 54
ccs 4
cts 6
cp 0.6667
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A work() 0 3 1
A __call() 0 3 1
A miniProgram() 0 3 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
namespace EasyWeChat\OpenWork;
13
14
use EasyWeChat\Kernel\ServiceContainer;
15
use EasyWeChat\OpenWork\Work\Application as Work;
16
17
/**
18
 * Application.
19
 *
20
 * @author xiaomin <[email protected]>
21
 *
22
 * @property \EasyWeChat\OpenWork\Server\Guard            $server
23
 * @property \EasyWeChat\OpenWork\Corp\Client             $corp
24
 * @property \EasyWeChat\OpenWork\Provider\Client         $provider
25
 * @property \EasyWeChat\OpenWork\SuiteAuth\AccessToken   $suite_access_token
26
 * @property \EasyWeChat\OpenWork\Auth\AccessToken        $provider_access_token
27
 * @property \EasyWeChat\OpenWork\SuiteAuth\SuiteTicket   $suite_ticket
28
 * @property \EasyWeChat\OpenWork\MiniProgram\Auth\Client $mini_program
29
 */
30
class Application extends ServiceContainer
31
{
32
    /**
33
     * @var array
34
     */
35
    protected $providers = [
36
        Auth\ServiceProvider::class,
37
        SuiteAuth\ServiceProvider::class,
38
        Server\ServiceProvider::class,
39
        Corp\ServiceProvider::class,
40
        Provider\ServiceProvider::class,
41
        MiniProgram\ServiceProvider::class,
42
    ];
43
44
    /**
45
     * @var array
46
     */
47
    protected $defaultConfig = [
48
        // http://docs.guzzlephp.org/en/stable/request-options.html
49
        'http' => [
50
            'base_uri' => 'https://qyapi.weixin.qq.com/',
51
        ],
52
    ];
53
54
    /**
55
     * Creates the miniProgram application.
56
     *
57
     * @return \EasyWeChat\Work\MiniProgram\Application
58
     */
59
    public function miniProgram(): \EasyWeChat\Work\MiniProgram\Application
60
    {
61
        return new \EasyWeChat\Work\MiniProgram\Application($this->getConfig());
62
    }
63
64
    /**
65
     * @param string $authCorpId    企业 corp_id
66
     * @param string $permanentCode 企业永久授权码
67
     *
68
     * @return Work
69
     */
70 1
    public function work(string $authCorpId, string $permanentCode): Work
71
    {
72 1
        return new Work($authCorpId, $permanentCode, $this);
73
    }
74
75
    /**
76
     * @param string $method
77
     * @param array  $arguments
78
     *
79
     * @return mixed
80
     */
81 1
    public function __call($method, $arguments)
82
    {
83 1
        return $this['base']->$method(...$arguments);
84
    }
85
}
86