Completed
Pull Request — master (#1275)
by
unknown
03:05
created

AccessToken::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of the keacefull/wechat.
4
 *
5
 * (c) xiaomin <[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;
0 ignored issues
show
Coding Style introduced by
There must be a single space after the USE keyword
Loading history...
14
use EasyWeChat\OpenWork\Application;
15
use Pimple\Container;
16
17
/**
18
 * Class AccessToken
19
 * @package EasyWeChat\OpenWork\Work\Auth
20
 */
21
class AccessToken extends BaseAccessToken
22
{
23
    /**
24
     * @var string
25
     */
26
    protected $requestMethod = 'POST';
27
28
    /**
29
     * @var String 授权方企业ID
30
     */
31
    protected $auth_corpid;
32
33
    /**
34
     * @var String 授权方企业永久授权码,通过get_permanent_code获取
35
     */
36
    protected $permanent_code;
37
38
39
    protected $component;
40
41
    /**
42
     * AccessToken constructor.
43
     * @param Container $app
44
     * @param String $auth_corpid
45
     * @param String $permanent_code
46
     * @param Application $component
47
     */
48
    public function __construct(Container $app, String $auth_corpid, String $permanent_code,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

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