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