LiveCommand   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 19 1
1
<?php
2
3
namespace Orkhanahmadov\LaravelCurrencylayer\Commands;
4
5
use Orkhanahmadov\LaravelCurrencylayer\Contracts\CurrencyService;
6
7
class LiveCommand extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'currencylayer:live 
15
                            {source : Source currency code} 
16
                            {currencies* : Target currency codes}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Gets live rates for currencies';
24
25
    /**
26
     * Execute the console command.
27
     *
28
     * @param CurrencyService $currencyService
29
     */
30
    public function handle(CurrencyService $currencyService): void
31
    {
32
        /**
33
         * @var array|float
34
         */
35
        $rates = $currencyService->live(
36
            /**
37
             * @var string
38
             */
39
            $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::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

39
            /** @scrutinizer ignore-type */ $source = $this->argument('source'),
Loading history...
40
            /**
41
             * @var array
42
             */
43
            $currencies = $this->argument('currencies')
44
        );
45
46
        $this->output(
47
            'Live '.$source.' rates',
0 ignored issues
show
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

47
            'Live './** @scrutinizer ignore-type */ $source.' rates',
Loading history...
48
            $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

48
            $this->prepareRows(/** @scrutinizer ignore-type */ $currencies, $rates)
Loading history...
49
        );
50
    }
51
}
52