Passed
Push — master ( 1c83bb...da7d31 )
by Orkhan
02:52
created

RateCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 1 Features 0
Metric Value
cc 1
eloc 7
c 6
b 1
f 0
nc 1
nop 1
dl 0
loc 23
rs 10
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Commands;
4
5
use Orkhanahmadov\LaravelCurrencylayer\Currencylayer;
6
7
class RateCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'currencylayer:rate 
15
                            {source : Source currency code} 
16
                            {date : Date for currency rates} 
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
     * Execute the console command.
28
     *
29
     * @param Currencylayer $currencylayer
30
     */
31
    public function handle(Currencylayer $currencylayer): void
32
    {
33
        /**
34
         * @var array|float $rates
35
         */
36
        $rates = $currencylayer->rate(
37
            /**
38
             * @var string $source
39
             */
40
            $source = $this->argument('source'),
0 ignored issues
show
Bug introduced by
It seems like $source = $this->argument('source') can also be of type string[]; however, parameter $source of Orkhanahmadov\LaravelCur...r\Currencylayer::rate() 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

40
            /** @scrutinizer ignore-type */ $source = $this->argument('source'),
Loading history...
41
            /**
42
             * @var string $date
43
             */
44
            $date = $this->argument('date'),
0 ignored issues
show
Bug introduced by
It seems like $date = $this->argument('date') can also be of type string[]; however, parameter $date of Orkhanahmadov\LaravelCur...r\Currencylayer::rate() does only seem to accept Carbon\Carbon|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

44
            /** @scrutinizer ignore-type */ $date = $this->argument('date'),
Loading history...
45
            /**
46
             * @var array $currencies
47
             */
48
            $currencies = $this->argument('currencies')
49
        );
50
51
        $this->output(
52
            $date.' '.$source.' rates',
53
            $this->prepareRows($currencies, $rates)
54
        );
55
    }
56
}
57