UpdateCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 8
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 6
1
<?php namespace Arcanedev\GeoIP\Console;
2
3
use Arcanedev\GeoIP\Contracts\GeoIPDriver;
4
use Arcanedev\Support\Bases\Command;
5
6
/**
7
 * Class     UpdateCommand
8
 *
9
 * @package  Arcanedev\GeoIP\Console
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class UpdateCommand extends Command
13
{
14
    /* -----------------------------------------------------------------
15
     |  Properties
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * The console command name.
21
     *
22
     * @var string
23
     */
24
    protected $name = 'geoip:update';
25
26
    /**
27
     * The console command description.
28
     *
29
     * @var string
30
     */
31
    protected $description = 'Update GeoIP database files to the latest version';
32
33
    /** @var  \Arcanedev\GeoIP\Contracts\GeoIPDriver */
34
    protected $driver;
35
36
    /* -----------------------------------------------------------------
37
     |  Constructor
38
     | -----------------------------------------------------------------
39
     */
40
41
    /**
42
     * UpdateCommand constructor.
43
     *
44
     * @param  \Arcanedev\GeoIP\Contracts\GeoIPDriver  $driver
45
     */
46
    public function __construct(GeoIPDriver $driver)
47
    {
48
        parent::__construct();
49
50
        $this->driver = $driver;
51
    }
52
53
    /* -----------------------------------------------------------------
54
     |  Main Methods
55
     | -----------------------------------------------------------------
56
     */
57
58
    /**
59
     * Execute the console command.
60
     */
61
    public function handle()
62
    {
63
        $this->comment('Updating the driver database...');
64
65
        if ($this->driver->update())
66
            $this->info('Driver database updated');
67
        else
68
            $this->error('Update failed!');
69
    }
70
}
71