Completed
Pull Request — master (#1414)
by milkmeowo
04:39
created

AccessToken   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 55
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getEndpoint() 0 4 1
A getCredentials() 0 5 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\Work\Auth;
13
14
use EasyWeChat\Kernel\AccessToken as BaseAccessToken;
15
use EasyWeChat\OpenWork\Application;
16
use Pimple\Container;
17
18
/**
19
 * AccessToken.
20
 *
21
 * @author xiaomin <[email protected]>
22
 */
23
class AccessToken extends BaseAccessToken
24
{
25
    /**
26
     * @var string
27
     */
28
    protected $requestMethod = 'POST';
29
30
    /**
31
     * @var string 授权方企业ID
32
     */
33
    protected $authCorpid;
34
35
    /**
36
     * @var string 授权方企业永久授权码,通过get_permanent_code获取
37
     */
38
    protected $permanentCode;
39
40
    protected $component;
41
42
    /**
43
     * AccessToken constructor.
44
     *
45
     * @param Container   $app
46
     * @param string      $authCorpId
47
     * @param string      $permanentCode
48
     * @param Application $component
49
     */
50 3
    public function __construct(Container $app, String $authCorpId, String $permanentCode, Application $component)
51
    {
52 3
        $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...
53 3
        $this->permanentCode = $permanentCode;
54 3
        $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...
55 3
        parent::__construct($app);
56 3
    }
57
58
    /**
59
     * Credential for get token.
60
     *
61
     * @return array
62
     */
63 1
    protected function getCredentials(): array
64
    {
65
        return [
66 1
            'auth_corpid' => $this->authCorpid,
67 1
            'permanent_code' => $this->permanentCode,
68
        ];
69
    }
70
71
    /**
72
     * @return string
73
     */
74 1
    public function getEndpoint(): string
75
    {
76 1
        return 'cgi-bin/service/get_corp_token?'.http_build_query([
77 1
                'suite_access_token' => $this->component['suite_access_token']->getToken()['suite_access_token'],
78
            ]);
79
    }
80
}
81