Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -47,9 +47,9 @@ class DownloadExchangeRates implements ShouldQueue
use Queueable;
use SerializesModels;
private array $active;
private Carbon $date;
private CurrencyRepositoryInterface $repository;
private array $active;
private Collection $users;
/**
@@ -57,7 +57,7 @@ class DownloadExchangeRates implements ShouldQueue
*
* @codeCoverageIgnore
*
* @param Carbon|null $date
* @param Carbon|null $date
*/
public function __construct(?Carbon $date)
{
@@ -92,23 +92,13 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
/**
* @param TransactionCurrency $currency
* @param TransactionCurrency $currency
* @return void
*/
private function downloadRates(TransactionCurrency $currency): void
{
Log::debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));
$base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);
$base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);
$client = new Client();
$url = sprintf('%s/%s.json', $base, $currency->code);
$res = $client->get($url);
@@ -117,7 +107,7 @@ class DownloadExchangeRates implements ShouldQueue
app('log')->warning(sprintf('Trying to grab "%s" resulted in status code %d.', $url, $statusCode));
return;
}
$body = (string) $res->getBody();
$body = (string)$res->getBody();
$json = json_decode($body, true);
if (false === $json || null === $json) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));
@@ -128,8 +118,8 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param TransactionCurrency $currency
* @param array $rates
* @param TransactionCurrency $currency
* @param array $rates
* @return void
*/
private function saveRates(TransactionCurrency $currency, Carbon $date, array $rates): void
@@ -146,7 +136,7 @@ class DownloadExchangeRates implements ShouldQueue
}
/**
* @param string $code
* @param string $code
* @return TransactionCurrency|null
*/
private function getCurrency(string $code): ?TransactionCurrency
@@ -185,4 +175,14 @@ class DownloadExchangeRates implements ShouldQueue
}
}
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$newDate = clone $date;
$newDate->startOfDay();
$this->date = $newDate;
}
}