@@ 141-164 (lines=24) @@ | ||
138 | /** |
|
139 | * {@inheritdoc} |
|
140 | */ |
|
141 | public function latest($sourceName, $currencyCode, $rateType = RateType::MEDIAN, \DateTimeInterface $date = null) |
|
142 | { |
|
143 | /** |
|
144 | * @var RateInterface $rate |
|
145 | */ |
|
146 | foreach ($this->rates as $rate) { |
|
147 | ||
148 | if (null !== $date && $date < $rate->getDate()) { |
|
149 | continue; |
|
150 | } |
|
151 | ||
152 | if ( |
|
153 | $rate->getSourceName() === $sourceName |
|
154 | && |
|
155 | $rate->getCurrencyCode() === $currencyCode |
|
156 | && |
|
157 | $rate->getRateType() === $rateType |
|
158 | ) { |
|
159 | return $rate; |
|
160 | } |
|
161 | } |
|
162 | ||
163 | throw new ExchangeRateException(sprintf('Could not fetch latest rate for rate currency code "%s" and rate type "%s" from source "%s".', $currencyCode, $rateType, $sourceName)); |
|
164 | } |
|
165 | ||
166 | /** |
|
167 | * {@inheritdoc} |
@@ 98-121 (lines=24) @@ | ||
95 | /** |
|
96 | * {@inheritdoc} |
|
97 | */ |
|
98 | public function latest($sourceName, $currencyCode, $rateType = RateType::MEDIAN, \DateTimeInterface $date = null) |
|
99 | { |
|
100 | /** |
|
101 | * @var RateInterface $rate |
|
102 | */ |
|
103 | foreach ($this->rates as $rate) { |
|
104 | ||
105 | if (null !== $date && $date < $rate->getDate()) { |
|
106 | continue; |
|
107 | } |
|
108 | ||
109 | if ( |
|
110 | $rate->getSourceName() === $sourceName |
|
111 | && |
|
112 | $rate->getCurrencyCode() === $currencyCode |
|
113 | && |
|
114 | $rate->getRateType() === $rateType |
|
115 | ) { |
|
116 | return $rate; |
|
117 | } |
|
118 | } |
|
119 | ||
120 | throw new ExchangeRateException(sprintf('Could not fetch latest rate for rate currency code "%s" and rate type "%s" from source "%s".', $currencyCode, $rateType, $sourceName)); |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * {@inheritdoc} |