Conditions | 5 |
Paths | 17 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
38 | public function getRouteName(string $resourceClass, bool $collection) : string |
||
39 | { |
||
40 | $cacheKey = self::CACHE_KEY_PREFIX.md5(serialize([$resourceClass, $collection])); |
||
41 | |||
42 | try { |
||
43 | $cacheItem = $this->cacheItemPool->getItem($cacheKey); |
||
44 | |||
45 | if ($cacheItem->isHit()) { |
||
46 | return $cacheItem->get(); |
||
47 | } |
||
48 | } catch (CacheException $e) { |
||
49 | // do nothing |
||
50 | } |
||
51 | |||
52 | $routeName = $this->decorated->getRouteName($resourceClass, $collection); |
||
53 | |||
54 | if (isset($cacheItem)) { |
||
55 | try { |
||
56 | $cacheItem->set($routeName); |
||
57 | $this->cacheItemPool->save($cacheItem); |
||
58 | } catch (CacheException $e) { |
||
59 | // do nothing |
||
60 | } |
||
61 | } |
||
62 | |||
63 | return $routeName; |
||
64 | } |
||
65 | } |
||
66 |