| Conditions | 4 |
| Paths | 7 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | public function return(string $key, callable $callback) |
||
| 38 | { |
||
| 39 | try { |
||
| 40 | if ($this->cache->has(hash('sha256', $key))) { |
||
| 41 | return $this->cache->get(hash('sha256', $key)); |
||
| 42 | } |
||
| 43 | } catch (InvalidArgumentException $e) { |
||
| 44 | $this->logger->warning('Used invalid key as cache key "' . $key . '" - handled as miss'); |
||
| 45 | } |
||
| 46 | $result = $callback($key); |
||
| 47 | /** @noinspection UnSafeIsSetOverArrayInspection */ |
||
| 48 | if (!isset($e)) { |
||
| 49 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
| 50 | $this->cache->set(hash('sha256', $key), $result); |
||
| 51 | } |
||
| 52 | return $result; |
||
| 53 | } |
||
| 55 |