Passed
Push — master ( 13f560...b9fd0b )
by Orkhan
02:14
created

LiveCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Commands;
4
5
use Illuminate\Console\Command;
6
use Orkhanahmadov\LaravelCurrencylayer\Currencylayer;
7
8
class LiveCommand extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'currencylayer:live 
16
                            {source : Source currency code} 
17
                            {currencies* : Target currency codes}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Gets live rates for currencies';
25
26
    /**
27
     * Create a new command instance.
28
     *
29
     * @return void
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
    }
35
36
    /**
37
     * Execute the console command.
38
     *
39
     * @param Currencylayer $currencylayer
40
     *
41
     * @return mixed
42
     */
43
    public function handle(Currencylayer $currencylayer)
44
    {
45
        $rates = $currencylayer->live(
46
            $this->argument('source'),
0 ignored issues
show
Bug introduced by
It seems like $this->argument('source') can also be of type string[]; however, parameter $source of Orkhanahmadov\LaravelCur...r\Currencylayer::live() does only seem to accept Orkhanahmadov\LaravelCur...\Models\Currency|string, maybe add an additional type check? ( Ignorable by Annotation )

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

46
            /** @scrutinizer ignore-type */ $this->argument('source'),
Loading history...
47
            $this->argument('currencies')
48
        );
49
50
        $header = ['Currency', 'Value'];
51
        if (is_array($rates)) {
52
            $this->table($header, [array_keys($rates), array_values($rates)]);
53
        } else {
54
            $this->table($header, [$this->argument('currencies'), [$rates]]);
55
        }
56
    }
57
}
58