Passed
Pull Request — master (#1278)
by
unknown
03:33
created

AccessToken   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getEndpoint() 0 4 1
A getCredentials() 0 5 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)
0 ignored issues
show
Unused Code introduced by
The parameter $component is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
    public function __construct(Container $app, String $authCorpId, String $permanentCode, /** @scrutinizer ignore-unused */ Application $component)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

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