UpdateCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 59
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 9 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