RateCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 8
Bugs 2 Features 0
Metric Value
wmc 1
eloc 10
c 8
b 2
f 0
dl 0
loc 47
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 23 1
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Commands;
4
5
use Orkhanahmadov\LaravelCurrencylayer\Contracts\CurrencyService;
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 CurrencyService $currencyService
30
     */
31
    public function handle(CurrencyService $currencyService): void
32
    {
33
        /**
34
         * @var array|float
35
         */
36
        $rates = $currencyService->rate(
37
            /**
38
             * @var string
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...CurrencyService::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
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...CurrencyService::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
47
             */
48
            $currencies = $this->argument('currencies')
49
        );
50
51
        $this->output(
52
            $date.' '.$source.' rates',
0 ignored issues
show
Bug introduced by
Are you sure $date of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

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

52
            /** @scrutinizer ignore-type */ $date.' '.$source.' rates',
Loading history...
Bug introduced by
Are you sure $source of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

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

52
            $date.' './** @scrutinizer ignore-type */ $source.' rates',
Loading history...
53
            $this->prepareRows($currencies, $rates)
0 ignored issues
show
Bug introduced by
It seems like $currencies can also be of type null and string; however, parameter $currencies of Orkhanahmadov\LaravelCur...\Command::prepareRows() does only seem to accept array, 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

53
            $this->prepareRows(/** @scrutinizer ignore-type */ $currencies, $rates)
Loading history...
54
        );
55
    }
56
}
57