@@ -45,20 +45,20 @@ |
||
45 | 45 | public function registerSchedule($schedule) |
46 | 46 | { |
47 | 47 | // Exchange service daily update when allowed by Settings |
48 | - $schedule->call(function () { |
|
48 | + $schedule->call(function() { |
|
49 | 49 | $cnb = $this->app->make('cnb'); |
50 | 50 | $cnb->updateTodayExchangeRates(); |
51 | 51 | |
52 | - })->daily()->when(function () { |
|
52 | + })->daily()->when(function() { |
|
53 | 53 | return !!Settings::get('exchange', true); |
54 | 54 | }); |
55 | 55 | |
56 | 56 | // PRIBOR service daily update when allowed by Settings |
57 | - $schedule->call(function () { |
|
57 | + $schedule->call(function() { |
|
58 | 58 | $cnb = $this->app->make('cnb'); |
59 | 59 | $cnb->updateTodayPriborRates(); |
60 | 60 | |
61 | - })->daily()->when(function () { |
|
61 | + })->daily()->when(function() { |
|
62 | 62 | return !!Settings::get('pribor', true); |
63 | 63 | }); |
64 | 64 | } |
@@ -1,6 +1,5 @@ |
||
1 | 1 | <?php namespace VojtaSvoboda\CnbRates; |
2 | 2 | |
3 | -use Backend; |
|
4 | 3 | use System\Classes\PluginBase; |
5 | 4 | use VojtaSvoboda\CnbRates\Models\Settings; |
6 | 5 |
@@ -6,12 +6,12 @@ |
||
6 | 6 | |
7 | 7 | class Settings extends Model |
8 | 8 | { |
9 | - public $implement = ['System.Behaviors.SettingsModel']; |
|
9 | + public $implement = ['System.Behaviors.SettingsModel']; |
|
10 | 10 | |
11 | - // A unique code |
|
12 | - public $settingsCode = 'vojtasvoboda_cnbrates_settings'; |
|
11 | + // A unique code |
|
12 | + public $settingsCode = 'vojtasvoboda_cnbrates_settings'; |
|
13 | 13 | |
14 | - // Reference to field configuration |
|
15 | - public $settingsFields = 'fields.yaml'; |
|
14 | + // Reference to field configuration |
|
15 | + public $settingsFields = 'fields.yaml'; |
|
16 | 16 | |
17 | 17 | } |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function getData($url, $date = null, $ident = null) |
28 | 28 | { |
29 | - if(!$url) { |
|
29 | + if (!$url) { |
|
30 | 30 | throw new \Exception("Service URL can't be empty."); |
31 | 31 | } |
32 | 32 | |
33 | 33 | $dateObj = new \DateTime($date); |
34 | 34 | $date = $dateObj->format('d.m.Y'); |
35 | 35 | |
36 | - if(!$this->isFileExists($date, $ident)) { |
|
36 | + if (!$this->isFileExists($date, $ident)) { |
|
37 | 37 | $this->saveDataToFile($this->loadDataFromUrl($url), $date, $ident); |
38 | 38 | } |
39 | 39 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function getFilePath($date, $ident = null) |
109 | 109 | { |
110 | - if(!$ident) { |
|
110 | + if (!$ident) { |
|
111 | 111 | $ident = $this->undefinedFolderName; |
112 | 112 | } |
113 | 113 | |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | private function checkCacheFolder($ident) |
123 | 123 | { |
124 | 124 | $cacheFolder = temp_path($this->cachePathPrefix . '/'); |
125 | - if(!file_exists($cacheFolder)) { |
|
125 | + if (!file_exists($cacheFolder)) { |
|
126 | 126 | mkdir($cacheFolder); |
127 | 127 | } |
128 | 128 | |
129 | - if(!$ident) { |
|
129 | + if (!$ident) { |
|
130 | 130 | $ident = $this->undefinedFolderName; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $identFolder = temp_path($this->cachePathPrefix . '/' . $ident . '/'); |
134 | - if(!file_exists($identFolder)) { |
|
134 | + if (!file_exists($identFolder)) { |
|
135 | 135 | mkdir($identFolder); |
136 | 136 | } |
137 | 137 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | { |
96 | 96 | $r = []; |
97 | 97 | $lines = preg_split('/\r\n|\n|\r/', trim($source)); |
98 | - foreach($lines as $key => $line) |
|
98 | + foreach ($lines as $key => $line) |
|
99 | 99 | { |
100 | 100 | // file headers |
101 | 101 | if ($key < 3) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param $date |
24 | 24 | * |
25 | - * @return array |
|
25 | + * @return string |
|
26 | 26 | */ |
27 | 27 | public function getDataSource($date = null) |
28 | 28 | { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param $date |
63 | 63 | * |
64 | - * @return mixed |
|
64 | + * @return string |
|
65 | 65 | */ |
66 | 66 | public function getSourceUrl($date = null) |
67 | 67 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Transform data source to array |
103 | 103 | * |
104 | - * @param $source |
|
104 | + * @param string $source |
|
105 | 105 | * @param int $keyIndex |
106 | 106 | * |
107 | 107 | * @return array |
@@ -20,7 +20,7 @@ |
||
20 | 20 | $rates = $this->getData($date, $keyIndex = 3); |
21 | 21 | $r = []; |
22 | 22 | |
23 | - foreach($rates as $key => $rate) |
|
23 | + foreach ($rates as $key => $rate) |
|
24 | 24 | { |
25 | 25 | if (sizeof($rate) >= 4) |
26 | 26 | { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | $intervalKeys = $this->getIntervalKeys(); |
22 | 22 | $r = []; |
23 | 23 | |
24 | - foreach($data as $key => $rate) { |
|
24 | + foreach ($data as $key => $rate) { |
|
25 | 25 | if (isset($intervalKeys[$key])) { |
26 | 26 | $r[$intervalKeys[$key]] = round(floatval(strtr($rate[2], [',' => '.'])), 2); |
27 | 27 | } |