Passed
Push — master ( 1eac36...3fff91 )
by Thomas
10:26
created
database/migrations/2020_07_13_223305_create_exchange_rates_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('exchange_rates', function (Blueprint $table) {
16
+        Schema::create('exchange_rates', function(Blueprint $table) {
17 17
             $table->date('date')->unique();
18 18
             $table->json('rates');
19 19
         });
Please login to merge, or discard this patch.
src/Commands/SyncRatesCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
         $begin = new DateTime($this->argument('date') ?? date('Y-m-d'));
23 23
         $end   = new DateTime($this->argument('endDate') ?? date('Y-m-d'));
24 24
 
25
-        if($begin != $end) {
26
-            $period  = new DatePeriod($begin, DateInterval::createFromDateString('1 day'), $end);
27
-            foreach ($period as $dt){
25
+        if ($begin != $end) {
26
+            $period = new DatePeriod($begin, DateInterval::createFromDateString('1 day'), $end);
27
+            foreach ($period as $dt) {
28 28
                 $this->syncRates($dt);
29 29
             }
30
-        }else{
30
+        }else {
31 31
             $this->syncRates($begin);
32 32
         }
33 33
         ExchangeRate::insertOrIgnore($this->rates);
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
     private function syncRates(DateTime $dt) : void
37 37
     {
38 38
         $rates = Tcmb::fetchRates($dt);
39
-        if($rates){
39
+        if ($rates) {
40 40
             $this->info($dt->format('d.m.Y') . ' synced');
41 41
             array_push($this->rates, ['date' => $dt->format('Y-m-d'), 'rates' => json_encode($rates)]);
42
-        }else{
42
+        }else {
43 43
             $this->error($dt->format('d.m.Y') . ' not synced');
44 44
         }
45 45
     }
Please login to merge, or discard this patch.
src/Tcmb.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@
 block discarded – undo
65 65
 	       	if ($rates && array_key_exists($to, $rates) && array_key_exists($from, $rates) && $rates[$to]['buy'] > 0 && $rates[$from]['sell'] > 0) {
66 66
 		        $base = 'TRY';
67 67
 	            if ($from === $base) {
68
-	                $amount = $amount / (float)$rates[$to]['buy'];
68
+	                $amount = $amount/(float)$rates[$to]['buy'];
69 69
 	            } elseif ($to === $base) {
70
-	                $amount = $amount * (float)$rates[$from]['sell'];
71
-	            } else {
72
-	                $amount = $amount * (float)$rates[$from]['sell'] / (float)$rates[$to]['buy'];
70
+	                $amount = $amount*(float)$rates[$from]['sell'];
71
+	            }else {
72
+	                $amount = $amount*(float)$rates[$from]['sell']/(float)$rates[$to]['buy'];
73 73
 	            }
74 74
 		    }
75 75
 		}
Please login to merge, or discard this patch.
src/TcmbServiceProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,17 +9,17 @@  discard block
 block discarded – undo
9 9
 {
10 10
     public function boot()
11 11
     {
12
-        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
13
-        $this->loadRoutesFrom(__DIR__.'/routes.php');
12
+        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
13
+        $this->loadRoutesFrom(__DIR__ . '/routes.php');
14 14
 
15 15
         if ($this->app->runningInConsole()) {
16 16
             
17 17
             $this->publishes([
18
-                __DIR__.'/../config/config.php' => config_path('tcmb.php'),
18
+                __DIR__ . '/../config/config.php' => config_path('tcmb.php'),
19 19
             ], 'config');
20 20
 
21 21
             $this->publishes([
22
-                __DIR__.'/../database/migrations/' => database_path('migrations')
22
+                __DIR__ . '/../database/migrations/' => database_path('migrations')
23 23
             ], 'migrations');
24 24
 
25 25
             $this->commands([
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function register()
32 32
     {
33
-        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'tcmb');
34
-        $this->app->singleton('tcmb', function () {
33
+        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'tcmb');
34
+        $this->app->singleton('tcmb', function() {
35 35
             return new Tcmb;
36 36
         });
37 37
     }
Please login to merge, or discard this patch.