Completed
Push — master ( 35062f...602a22 )
by Carlos
04:52 queued 02:12
created

MiniAppUser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
ccs 0
cts 17
cp 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A get() 0 11 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
/**
13
 * MiniAppUser.php.
14
 *
15
 * @author    soone <[email protected]>
16
 * @copyright 2016 soone <[email protected]>
17
 *
18
 * @see      https://github.com/overtrue
19
 * @see      http://overtrue.me
20
 */
21
22
namespace EasyWeChat\User;
23
24
use EasyWeChat\Core\AbstractAPI;
25
26
/**
27
 * Class MiniAppUser.
28
 */
29
class MiniAppUser extends AbstractAPI
30
{
31
    private $appId;
32
    private $secret;
33
    private $grantType = 'authorization_code';
34
    private $config;
35
36
    const API_JSCODE_SESSION = 'https://api.weixin.qq.com/sns/jscode2session';
37
38
    public function __construct($config)
39
    {
40
        $this->config = $config;
41
        $this->appId = $this->config['app_id'];
42
        $this->secret = $this->config['secret'];
43
        !empty($this->config['grant_type']) ? $this->grantType = $this->config['grant_type'] : '';
44
    }
45
46
    /**
47
     * Get openid session_key expires_in by js_code.
48
     *
49
     * @param string $openId
0 ignored issues
show
Bug introduced by
There is no parameter named $openId. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
50
     * @param string $lang
0 ignored issues
show
Bug introduced by
There is no parameter named $lang. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
51
     *
52
     * @return array
53
     */
54
    public function get($jsCode)
55
    {
56
        $params = [
57
                   'appid' => $this->appId,
58
                   'secret' => $this->secret,
59
                   'grant_type' => $this->grantType,
60
                   'js_code' => $jsCode,
61
                  ];
62
63
        return $this->parseJSON('get', [self::API_JSCODE_SESSION, $params]);
64
    }
65
}
66