Total Complexity | 10 |
Total Lines | 77 |
Duplicated Lines | 0 % |
Coverage | 58.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class AccessToken extends \SocialConnect\OAuth1\Token implements AccessTokenInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var string|null |
||
17 | */ |
||
18 | protected $userId; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $screenName; |
||
24 | |||
25 | 7 | public function __construct(array $token) |
|
26 | { |
||
27 | 7 | if (!isset($token['oauth_token'])) { |
|
28 | throw new InvalidAccessToken( |
||
29 | 'API returned data without oauth_token field' |
||
30 | ); |
||
31 | } |
||
32 | |||
33 | 7 | if (!isset($token['oauth_token_secret'])) { |
|
34 | throw new InvalidAccessToken( |
||
35 | 'API returned data without oauth_token_secret field' |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | 7 | parent::__construct($token['oauth_token'], $token['oauth_token_secret']); |
|
40 | |||
41 | 7 | if (isset($token['user_id'])) { |
|
42 | $this->userId = (string) $token['user_id']; |
||
43 | } |
||
44 | |||
45 | 7 | if (isset($token['screen_name'])) { |
|
46 | $this->screenName = $token['screen_name']; |
||
47 | } |
||
48 | 7 | } |
|
49 | |||
50 | /** |
||
51 | * @param string $userId |
||
52 | */ |
||
53 | 1 | public function setUserId(string $userId) |
|
54 | { |
||
55 | 1 | $this->userId = $userId; |
|
56 | 1 | } |
|
57 | |||
58 | /** |
||
59 | * @return string|null |
||
60 | */ |
||
61 | 1 | public function getUserId() |
|
62 | { |
||
63 | 1 | return $this->userId; |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getScreenName() |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return string|null |
||
76 | */ |
||
77 | 5 | public function getToken() |
|
78 | { |
||
79 | // It's a key, not a secret |
||
80 | 5 | return $this->key; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return int|null |
||
85 | */ |
||
86 | public function getExpires() |
||
90 | } |
||
91 | } |
||
92 |