Completed
Push — master ( ca015a...89855b )
by Wang
04:55
created

WebResourceOwner   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 91.3%

Importance

Changes 0
Metric Value
wmc 20
lcom 1
cbo 0
dl 0
loc 119
ccs 21
cts 23
cp 0.913
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 2
A getNickname() 0 4 2
A getSex() 0 4 2
A getCity() 0 4 2
A getCountry() 0 4 2
A getPrivilege() 0 4 2
A toArray() 0 4 1
A getProvince() 0 4 2
A getHeadImgUrl() 0 4 2
A getUnionId() 0 4 2
1
<?php
2
3
4
namespace Oakhope\OAuth2\Client\Provider;
5
6
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
7
8
class WebResourceOwner implements ResourceOwnerInterface
9
{
10
    /**
11
     * Raw response
12
     *
13
     * @var array
14
     */
15
    protected $response;
16
17
    /**
18
     * Creates new resource owner.
19
     *
20
     * @param array  $response
21
     */
22 6
    public function __construct(array $response = array())
23
    {
24 6
        $this->response = $response;
25 6
    }
26
27
    /**
28
     * 普通用户的标识,对当前开发者帐号唯一
29
     *
30
     * @return string|null
31
     */
32 3
    public function getId()
33
    {
34 3
        return $this->response['openid'] ?: null;
35
    }
36
37
    /**
38
     * 普通用户昵称
39
     *
40
     * @return string|null
41
     */
42 3
    public function getNickname()
43
    {
44 3
        return $this->response['nickname'] ?: null;
45
    }
46
47
    /**
48
     * 普通用户性别,1为男性,2为女性
49
     *
50
     * @return string|null
51
     */
52 3
    public function getSex()
53
    {
54 3
        return $this->response['sex'] ?: null;
55
    }
56
57
    /**
58
     * 普通用户个人资料填写的省份
59
     *
60
     * @return string|null
61
     */
62 3
    public function getProvince()
63
    {
64 3
        return $this->response['province'] ?: null;
65
    }
66
67
    /**
68
     * 普通用户个人资料填写的城市
69
     *
70
     * @return string|null
71
     */
72 3
    public function getCity()
73
    {
74 3
        return $this->response['city'] ?: null;
75
    }
76
77
    /**
78
     * 国家,如中国为CN
79
     *
80
     * @return string|null
81
     */
82 3
    public function getCountry()
83
    {
84 3
        return $this->response['country'] ?: null;
85
    }
86
87
    /**
88
     * 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空
89
     *
90
     * @return string|null
91
     */
92 3
    public function getHeadImgUrl()
93
    {
94 3
        return $this->response['headimgurl'] ?: null;
95
    }
96
97
    /**
98
     * 用户特权信息,json数组,如微信沃卡用户为(chinaunicom)
99
     *
100
     * @return string|null
101
     */
102 3
    public function getPrivilege()
103
    {
104 3
        return $this->response['privilege'] ?: null;
105
    }
106
107
    /**
108
     * 用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的
109
     *
110
     * @return string|null
111
     */
112 3
    public function getUnionId()
113
    {
114 3
        return $this->response['unionid'] ?: null;
115
    }
116
117
    /**
118
     * Return all of the owner details available as an array.
119
     *
120
     * @return array
121
     */
122
    public function toArray()
123
    {
124
        return $this->response;
125
    }
126
}
127