1 | <?php |
||
7 | class BaseService |
||
8 | { |
||
9 | protected $dataProvider; |
||
10 | |||
11 | protected $baseUrl; |
||
12 | |||
13 | protected $ident; |
||
14 | |||
15 | public function __construct(CnbDataProvider $dataProvider) |
||
19 | |||
20 | /** |
||
21 | * Return service data |
||
22 | * |
||
23 | * @param $date |
||
24 | * |
||
25 | * @return array |
||
26 | */ |
||
27 | public function getDataSource($date = null) |
||
31 | |||
32 | /** |
||
33 | * Get data as array |
||
34 | * |
||
35 | * @param null $date |
||
36 | * @param int $keyIndex |
||
37 | * |
||
38 | * @return array |
||
39 | * |
||
40 | * @throws \Exception |
||
41 | */ |
||
42 | public function getData($date = null, $keyIndex = 0) |
||
48 | |||
49 | /** |
||
50 | * Get service identifier |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function getIdent() |
||
58 | |||
59 | /** |
||
60 | * Get service source URL |
||
61 | * |
||
62 | * @param $date |
||
63 | * |
||
64 | * @return mixed |
||
65 | */ |
||
66 | public function getSourceUrl($date = null) |
||
75 | |||
76 | /** |
||
77 | * Returns service base URL |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public function getBaseUrl() |
||
85 | |||
86 | /** |
||
87 | * Convert price string to float number |
||
88 | * |
||
89 | * @param $string |
||
90 | * @param $rounding |
||
91 | * |
||
92 | * @return float |
||
93 | */ |
||
94 | public function priceStringToFloat($string, $rounding = 2) |
||
100 | |||
101 | /** |
||
102 | * Transform data source to array |
||
103 | * |
||
104 | * @param $source |
||
105 | * @param int $keyIndex |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | private function transformSourceToArray($source, $keyIndex = 0) |
||
128 | } |