1: <?php
2: namespace Sotr\Crypto\Btce;
3:
4: use RuntimeException;
5:
6: use Sotr\Crypto\CurrencyPair;
7: use Sotr\Crypto\CurrencyPairResolverInterface;
8:
9: class BtceCurrencyPairResolver implements CurrencyPairResolverInterface
10: {
11: public function resolve(CurrencyPair $pair)
12: {
13: $currencies = $pair->getCurrencies();
14: if (in_array('btc', $currencies) && in_array('usd', $currencies)) {
15: return 'btc_usd';
16: }
17: if (in_array('ltc', $currencies) && in_array('usd', $currencies)) {
18: return 'ltc_usd';
19: }
20: if (in_array('btc', $currencies) && in_array('eur', $currencies)) {
21: return 'btc_eur';
22: }
23: if (in_array('ltc', $currencies) && in_array('eur', $currencies)) {
24: return 'ltc_eur';
25: }
26: throw new RuntimeException("Pair {$currencies[0]}-{$currencies[1]} is not supported or is invalid\n");
27: }
28: }
29: