| Conditions | 5 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 56 | public function getToken($updating = false) |
||
| 57 | { |
||
| 58 | $key = 'sobot_' . substr(md5(json_encode([__METHOD__, $this->getAppId()])), -5); |
||
| 59 | if (!is_null($this->cache) && !$updating && $this->cache->exists($key)) { |
||
| 60 | return $this->cache->get($key); |
||
| 61 | } |
||
| 62 | /** @var Response $res */ |
||
| 63 | $res = $this->request(); |
||
| 64 | $token = $res->item->token; |
||
| 65 | $expires = $res->item->expires_in; |
||
| 66 | !is_null($this->cache) && $this->cache->set($key, $token, $expires); |
||
| 67 | return $token; |
||
| 68 | } |
||
| 69 | } |