Conditions | 5 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5.0114 |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
33 | 2 | public function buildToken(array $tokenData) |
|
34 | { |
||
35 | 2 | if (empty($tokenData['access_token']) || |
|
36 | 2 | empty($tokenData['refresh_token']) || |
|
37 | 2 | empty($tokenData['expires_in']) || |
|
38 | 2 | empty($tokenData['account_id'])) { |
|
39 | throw new \InvalidArgumentException(); |
||
40 | } |
||
41 | |||
42 | 2 | $tokenClass = $this->objectMapper->getTokenClass(); |
|
43 | |||
44 | /** @var TokenInterface $token */ |
||
45 | 2 | $token = new $tokenClass(); |
|
46 | $token |
||
47 | 2 | ->setAccessToken($tokenData['access_token']) |
|
48 | 2 | ->setRefreshToken($tokenData['refresh_token']) |
|
49 | 2 | ->setExpiresAt($tokenData['expires_in'] + time()) |
|
50 | 2 | ->setAccountId($tokenData['account_id']); |
|
51 | |||
52 | 2 | return $token; |
|
53 | } |
||
54 | } |