Passed
Push — master ( f17217...1fc1f2 )
by Dong
08:32
created

getAccessToken()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 18
rs 9.7666
cc 4
nc 5
nop 4
1
<?php
2
3
namespace Dongdavid\Notify;
4
5
use Dongdavid\Notify\utils\Http;
6
7
// 如果没有cache方法就自定义一个方法用redis做缓存
8
if (!function_exists('getAccessToken')) {
9
    function getAccessToken($type,$appId,$appSecret,$agentid = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $agentid 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

9
    function getAccessToken($type,$appId,$appSecret,/** @scrutinizer ignore-unused */ $agentid = 0)

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...
10
    {
11
        switch ($type){
12
            case 'wechatoffical':
13
                $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appId}&secret={$appSecret}";
14
                break;
15
            case 'miniprogram':
16
                $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appId}&secret={$appSecret}";
17
                break;
18
            default:
19
                return '类型错误';
20
        }
21
        echo $url;
22
        $res = Http::get($url);
23
        if (isset($res['access_token'])){
24
            return $res;
25
        }else{
26
            return $res;
27
        }
28
29
30
31
    }
32
}