UpdateCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
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