Completed
Push — master ( 2addb1...4d5931 )
by Carlos
08:01 queued 02:29
created

AccessToken   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 55
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEndpoint() 0 4 1
A getCredentials() 0 5 1
A __construct() 0 6 1
1
<?php
2
/*
3
 * This file is part of the overtrue/wechat.
4
 *
5
 * (c) overtrue <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace EasyWeChat\OpenWork\Work\Auth;
12
13
use EasyWeChat\Kernel\AccessToken as BaseAccessToken;
14
use EasyWeChat\OpenWork\Application;
15
use Pimple\Container;
16
17
/**
18
 * AccessToken.
19
 *
20
 * @author xiaomin <[email protected]>
21
 */
22
class AccessToken extends BaseAccessToken
23
{
24
    /**
25
     * @var string
26
     */
27
    protected $requestMethod = 'POST';
28
29
    /**
30
     * @var String 授权方企业ID
31
     */
32
    protected $authCorpid;
33
34
    /**
35
     * @var String 授权方企业永久授权码,通过get_permanent_code获取
36
     */
37
    protected $permanentCode;
38
39
    protected $component;
40
41
    /**
42
     * AccessToken constructor.
43
     *
44
     * @param Container   $app
45
     * @param String      $authCorpId
46
     * @param String      $permanentCode
47
     * @param Application $component
48
     */
49
    public function __construct(Container $app, String $authCorpId, String $permanentCode, Application $component)
50
    {
51
        $this->authCorpid = $authCorpId;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
52
        $this->permanentCode = $permanentCode;
53
        $this->component = $component;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
54
        parent::__construct($app);
55
    }
56
57
    /**
58
     * Credential for get token.
59
     *
60
     * @return array
61
     */
62
    protected function getCredentials(): array
63
    {
64
        return [
65
            'auth_corpid'    => $this->authCorpid,
66
            'permanent_code' => $this->permanentCode,
67
        ];
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    public function getEndpoint(): string
74
    {
75
        return 'cgi-bin/service/get_corp_token?' . http_build_query([
76
                'suite_access_token' => $this->component['suite_access_token']->getToken()['suite_access_token'],
77
            ]);
78
    }
79
}
80