| Total Complexity | 8 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class Lti13Cache implements Lti1p3Cache |
||
| 7 | { |
||
| 8 | public const NONCE_PREFIX = 'nonce_'; |
||
| 9 | |||
| 10 | private $cache; |
||
| 11 | |||
| 12 | public function getLaunchData($key) |
||
| 17 | } |
||
| 18 | |||
| 19 | public function cacheLaunchData($key, $jwtBody): Lti13Cache |
||
| 20 | { |
||
| 21 | $this->cache[$key] = $jwtBody; |
||
| 22 | $this->saveCache(); |
||
| 23 | |||
| 24 | return $this; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function cacheNonce($nonce): Lti13Cache |
||
| 28 | { |
||
| 29 | $this->cache['nonce'][$nonce] = true; |
||
| 30 | $this->saveCache(); |
||
| 31 | |||
| 32 | return $this; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function checkNonce($nonce): bool |
||
| 43 | } |
||
| 44 | |||
| 45 | private function loadCache() |
||
| 46 | { |
||
| 47 | $cache = file_get_contents(api_get_path(SYS_ARCHIVE_PATH).'lti_cache.txt'); |
||
| 48 | if (empty($cache)) { |
||
| 49 | file_put_contents(api_get_path(SYS_ARCHIVE_PATH).'lti_cache.txt', '{}'); |
||
| 50 | $this->cache = []; |
||
| 51 | } |
||
| 52 | $this->cache = json_decode($cache, true); |
||
| 53 | } |
||
| 54 | |||
| 55 | private function saveCache() |
||
| 58 | } |
||
| 59 | } |
||
| 60 |