Use PSR-12 code style

This commit is contained in:
James Cole
2022-10-30 12:24:51 +01:00
parent bdcd9825ec
commit b27fe59ab4
44 changed files with 414 additions and 332 deletions

View File

@@ -33,6 +33,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use Illuminate\Console\Command;
use Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class TransferCurrenciesCorrections
@@ -69,8 +71,8 @@ class TransferCurrenciesCorrections extends Command
*
* @return int
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function handle(): int
{
@@ -137,14 +139,14 @@ class TransferCurrenciesCorrections extends Command
/**
* @return bool
* @throws FireflyException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function isExecuted(): bool
{
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool) $configVar->data;
return (bool)$configVar->data;
}
return false;
@@ -168,7 +170,7 @@ class TransferCurrenciesCorrections extends Command
}
/**
* @param TransactionJournal $transfer
* @param TransactionJournal $transfer
*/
private function updateTransferCurrency(TransactionJournal $transfer): void
{
@@ -233,7 +235,7 @@ class TransferCurrenciesCorrections extends Command
/**
* Is this a split transaction journal?
*
* @param TransactionJournal $transfer
* @param TransactionJournal $transfer
*
* @return bool
* @codeCoverageIgnore
@@ -246,7 +248,7 @@ class TransferCurrenciesCorrections extends Command
/**
* Extract source transaction, source account + source account currency from the journal.
*
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @codeCoverageIgnore
*/
@@ -258,7 +260,7 @@ class TransferCurrenciesCorrections extends Command
}
/**
* @param TransactionJournal $transfer
* @param TransactionJournal $transfer
*
* @return Transaction|null
* @codeCoverageIgnore
@@ -269,7 +271,7 @@ class TransferCurrenciesCorrections extends Command
}
/**
* @param Account $account
* @param Account $account
*
* @return TransactionCurrency|null
*/
@@ -296,7 +298,7 @@ class TransferCurrenciesCorrections extends Command
/**
* Extract destination transaction, destination account + destination account currency from the journal.
*
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*
* @codeCoverageIgnore
*/
@@ -308,7 +310,7 @@ class TransferCurrenciesCorrections extends Command
}
/**
* @param TransactionJournal $transfer
* @param TransactionJournal $transfer
*
* @return Transaction|null
* @codeCoverageIgnore
@@ -371,7 +373,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
$this->sourceTransaction
->transaction_currency_id
= (int) $this->sourceCurrency->id;
= (int)$this->sourceCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->sourceTransaction->id,
@@ -392,7 +394,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->sourceCurrency
&& null === $this->sourceTransaction->foreign_amount
&& (int) $this->sourceTransaction->transaction_currency_id !== (int) $this->sourceCurrency->id
&& (int)$this->sourceTransaction->transaction_currency_id !== (int)$this->sourceCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -404,7 +406,7 @@ class TransferCurrenciesCorrections extends Command
Log::debug($message);
$this->line($message);
$this->count++;
$this->sourceTransaction->transaction_currency_id = (int) $this->sourceCurrency->id;
$this->sourceTransaction->transaction_currency_id = (int)$this->sourceCurrency->id;
$this->sourceTransaction->save();
}
}
@@ -418,7 +420,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
$this->destinationTransaction
->transaction_currency_id
= (int) $this->destinationCurrency->id;
= (int)$this->destinationCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->destinationTransaction->id,
@@ -439,7 +441,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->destinationCurrency
&& null === $this->destinationTransaction->foreign_amount
&& (int) $this->destinationTransaction->transaction_currency_id !== (int) $this->destinationCurrency->id
&& (int)$this->destinationTransaction->transaction_currency_id !== (int)$this->destinationCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -451,7 +453,7 @@ class TransferCurrenciesCorrections extends Command
Log::debug($message);
$this->line($message);
$this->count++;
$this->destinationTransaction->transaction_currency_id = (int) $this->destinationCurrency->id;
$this->destinationTransaction->transaction_currency_id = (int)$this->destinationCurrency->id;
$this->destinationTransaction->save();
}
}
@@ -463,7 +465,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixInvalidForeignCurrency(): void
{
if ((int) $this->destinationCurrency->id === (int) $this->sourceCurrency->id) {
if ((int)$this->destinationCurrency->id === (int)$this->sourceCurrency->id) {
// update both transactions to match:
$this->sourceTransaction->foreign_amount = null;
$this->sourceTransaction->foreign_currency_id = null;
@@ -497,7 +499,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixMismatchedForeignCurrency(): void
{
if ((int) $this->sourceCurrency->id !== (int) $this->destinationCurrency->id) {
if ((int)$this->sourceCurrency->id !== (int)$this->destinationCurrency->id) {
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
$this->sourceTransaction->foreign_currency_id = $this->destinationCurrency->id;
$this->destinationTransaction->transaction_currency_id = $this->sourceCurrency->id;
@@ -517,7 +519,7 @@ class TransferCurrenciesCorrections extends Command
private function fixSourceNullForeignAmount(): void
{
if (null === $this->sourceTransaction->foreign_amount && null !== $this->destinationTransaction->foreign_amount) {
$this->sourceTransaction->foreign_amount = bcmul((string) $this->destinationTransaction->foreign_amount, '-1');
$this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
$this->sourceTransaction->save();
$this->count++;
Log::debug(
@@ -537,7 +539,7 @@ class TransferCurrenciesCorrections extends Command
private function fixDestNullForeignAmount(): void
{
if (null === $this->destinationTransaction->foreign_amount && null !== $this->sourceTransaction->foreign_amount) {
$this->destinationTransaction->foreign_amount = bcmul((string) $this->sourceTransaction->foreign_amount, '-1');
$this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
$this->destinationTransaction->save();
$this->count++;
Log::debug(
@@ -553,11 +555,11 @@ class TransferCurrenciesCorrections extends Command
/**
* This method makes sure that the transaction journal uses the currency given in the source transaction.
*
* @param TransactionJournal $journal
* @param TransactionJournal $journal
*/
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
{
if ((int) $journal->transaction_currency_id !== (int) $this->sourceCurrency->id) {
if ((int)$journal->transaction_currency_id !== (int)$this->sourceCurrency->id) {
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
$journal->transaction_currency_id = $this->sourceCurrency->id;
$message = sprintf(