orkhanahmadov /
laravel-currencylayer
| 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
Loading history...
|
|||||||
| 41 | /** |
||||||
| 42 | * @var string |
||||||
| 43 | */ |
||||||
| 44 | $date = $this->argument('date'), |
||||||
|
0 ignored issues
–
show
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
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
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
Loading history...
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
Loading history...
|
|||||||
| 53 | $this->prepareRows($currencies, $rates) |
||||||
|
0 ignored issues
–
show
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
Loading history...
|
|||||||
| 54 | ); |
||||||
| 55 | } |
||||||
| 56 | } |
||||||
| 57 |