Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
35 | 6 | public function getTaxesForOrder(Order $order) |
|
36 | { |
||
37 | 6 | if (null === $this->cacheItemPool) { |
|
38 | 4 | return new TaxResponse($this->apiClient->taxForOrder($order->toArray())); |
|
39 | } |
||
40 | |||
41 | /** @var \Symfony\Component\Cache\CacheItem $cacheItem */ |
||
42 | 4 | $cacheItem = $this->cacheItemPool->getItem($order->getCacheKey()); |
|
43 | |||
44 | 4 | if (!$cacheItem->isHit()) { |
|
45 | 2 | $cacheItem->set(new TaxResponse($this->apiClient->taxForOrder($order->toArray()))); |
|
46 | 2 | $this->cacheItemPool->save($cacheItem); |
|
47 | 2 | $cacheItem->expiresAt(new \DateTime('+1 day')); |
|
48 | } |
||
49 | |||
50 | 4 | return $cacheItem->get(); |
|
51 | } |
||
52 | |||
61 |