1 | <?php |
||
11 | class CachedExchangeRateProvider implements ExchangeRatesProviderInterface |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var ExchangeRatesProviderInterface |
||
16 | */ |
||
17 | private $provider; |
||
18 | |||
19 | |||
20 | /** |
||
21 | * @var Cache |
||
22 | */ |
||
23 | private $cache; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | private $lifetime; |
||
29 | |||
30 | /** |
||
31 | * CachedExchangeRateProvider constructor. |
||
32 | * @param ExchangeRatesProviderInterface $provider |
||
33 | * @param Cache $cache |
||
34 | * @param int $lifetime |
||
35 | */ |
||
36 | public function __construct(ExchangeRatesProviderInterface $provider, Cache $cache, $lifetime = 10800) |
||
42 | |||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function getAllRatesExchanges(\DateTime $date = null) |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function getRatesExchanges(array $codes, \DateTime $date = null) |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function getRateExchange($code, \DateTime $date = null) |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function getRatesExchangesDynamic($code, \DateTime $firstDate, \DateTime $lastDate) |
||
93 | |||
94 | |||
95 | } |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: