Passed
Push — master ( 19bab8...ffce45 )
by Davide
31:32
created

RetrieveAllGpsCoordinates::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
namespace DavideCasiraghi\LaravelEventsCalendar\Console;
3
4
use Illuminate\Console\Command;
5
use DavideCasiraghi\LaravelEventsCalendar\Facades\LaravelEventsCalendar;
6
use DavideCasiraghi\LaravelEventsCalendar\Models\Country;
7
use DavideCasiraghi\LaravelEventsCalendar\Models\EventVenue;
8
9
class RetrieveAllGpsCoordinates extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature =  'retrieve-all-gps-coordinates';
17
    
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Assign to all the venues the corresponding GPS coordinates';
24
    
25
    /**
26
    * Create a new command instance.
27
    *
28
    * @return void
29
    */
30 152
   public function __construct()
31
   {
32 152
       parent::__construct();
33 152
   }
34
   
35
    /**
36
    * Execute the console command.
37
    *
38
    * @param  
39
    * @return mixed
40
    */
0 ignored issues
show
Documentation Bug introduced by
The doc comment @return at position 0 could not be parsed: Unknown type name '@return' at position 0 in @return.
Loading history...
41
    public function handle(){
42
        $eventVenues = EventVenue::all();
43
        foreach ($eventVenues as $key => $eventVenue) {
44
            // Get GPS coordinates
45
            $address = Country::getCountryName($eventVenue->country_id).', '.$eventVenue->city.', '.$eventVenue->address;
46
            $gpsCoordinates = LaravelEventsCalendar::getVenueGpsCoordinates($address);
0 ignored issues
show
Bug introduced by
The method getVenueGpsCoordinates() does not exist on DavideCasiraghi\LaravelE...s\LaravelEventsCalendar. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
            /** @scrutinizer ignore-call */ 
47
            $gpsCoordinates = LaravelEventsCalendar::getVenueGpsCoordinates($address);
Loading history...
47
            $eventVenue->lat = $gpsCoordinates['lat'];
48
            $eventVenue->lng = $gpsCoordinates['lng'];
49
            $eventVenue->save();
50
        }
51
    }
52
}
53