1 | <?php |
||
32 | class NationalBankOfSerbiaDomCrawlerSource implements SourceInterface |
||
33 | { |
||
34 | /** |
||
35 | * API - Source of rates from National bank of Serbia. |
||
36 | */ |
||
37 | const SOURCE = 'http://www.nbs.rs/kursnaListaModul/naZeljeniDan.faces'; |
||
38 | |||
39 | /** |
||
40 | * API - Name of source. |
||
41 | */ |
||
42 | const NAME = 'national_bank_of_serbia'; |
||
43 | |||
44 | use LoggerAwareTrait; |
||
45 | |||
46 | /** |
||
47 | * List of supported exchange rate types and currencies. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | private static $supports = array( |
||
52 | 'default' => array('EUR', 'AUD', 'CAD', 'CNY', 'HRK', 'CZK', 'DKK', 'HUF', 'JPY', 'KWD', 'NOK', 'RUB', 'SEK', 'CHF', |
||
53 | 'GBP', 'USD', 'BAM', 'PLN', 'ATS', 'BEF', 'FIM', 'FRF', 'DEM', 'GRD', 'IEP', 'ITL', 'LUF', 'PTE', |
||
54 | 'ESP'), |
||
55 | 'foreign_cache_buying' => array('EUR', 'CHF', 'USD'), |
||
56 | 'foreign_cache_selling' => array('EUR', 'CHF', 'USD'), |
||
57 | 'foreign_exchange_buying' => array('EUR', 'AUD', 'CAD', 'CNY', 'DKK', 'JPY', 'NOK', 'RUB', 'SEK', 'CHF', 'GBP', 'USD'), |
||
58 | 'foreign_exchange_selling' => array('EUR', 'AUD', 'CAD', 'CNY', 'DKK', 'JPY', 'NOK', 'RUB', 'SEK', 'CHF', 'GBP', 'USD') |
||
59 | ); |
||
60 | |||
61 | /** |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $cache; |
||
65 | |||
66 | /** |
||
67 | * @var Client |
||
68 | */ |
||
69 | protected $guzzleClient; |
||
70 | |||
71 | /** |
||
72 | * @var CookieJar |
||
73 | */ |
||
74 | protected $guzzleCookieJar; |
||
75 | |||
76 | 6 | public function __construct() |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 2 | public function getName() |
|
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | 6 | public function fetch($currencyCode, $rateType = 'default', \DateTime $date = null) |
|
124 | |||
125 | /** |
||
126 | * Check if currency code and rate type are supported by this source. |
||
127 | * |
||
128 | * @param string $currencyCode Currency code. |
||
129 | * @param string $rateType Rate type. |
||
130 | * @throws ConfigurationException If currency code is not supported by source and rate type. |
||
131 | * @throws UnknownRateTypeException If rate type is unknown. |
||
132 | */ |
||
133 | 4 | protected function validate($currencyCode, $rateType) |
|
143 | |||
144 | /** |
||
145 | * @param \DateTime $date |
||
146 | * @return RateInterface[] |
||
147 | * @throws SourceNotAvailableException |
||
148 | */ |
||
149 | 4 | protected function load(\DateTime $date, $rateType) |
|
190 | |||
191 | /** |
||
192 | * Get NBS's form CSRF token. |
||
193 | * |
||
194 | * @return string CSRF token. |
||
195 | */ |
||
196 | 4 | protected function getFormCsrfToken() |
|
216 | |||
217 | /** |
||
218 | * Execute HTTP request and get raw body response. |
||
219 | * |
||
220 | * @param string $url URL to fetch. |
||
221 | * @param string $method HTTP Method. |
||
222 | * @param array $params Params to send with request. |
||
223 | * @return string |
||
224 | */ |
||
225 | 4 | protected function executeHttpRequest($url, $method, array $query = array(), array $params = array()) |
|
237 | |||
238 | /** |
||
239 | * Get Guzzle Client. |
||
240 | * |
||
241 | * @return Client |
||
242 | */ |
||
243 | 4 | protected function getGuzzleClient() |
|
251 | |||
252 | /** |
||
253 | * Get Guzzle CookieJar. |
||
254 | * |
||
255 | * @return CookieJar |
||
256 | */ |
||
257 | 4 | protected function getGuzzleCookieJar() |
|
265 | } |
||
266 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.