mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Various code cleanup.
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Form;
|
||||
|
||||
use Amount as Amt;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -42,9 +42,9 @@ class CurrencyForm
|
||||
use FormSupport;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -54,13 +54,12 @@ class CurrencyForm
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
protected function currencyField(string $name, string $view, $value = null, array $options = null): string
|
||||
{
|
||||
@@ -77,7 +76,7 @@ class CurrencyForm
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
$preFilled = session('preFilled');
|
||||
$key = 'amount_currency_id_' . $name;
|
||||
$sentCurrencyId = isset($preFilled[$key]) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
|
||||
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
@@ -96,7 +95,7 @@ class CurrencyForm
|
||||
}
|
||||
try {
|
||||
$html = prefixView('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
||||
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
}
|
||||
@@ -107,12 +106,11 @@ class CurrencyForm
|
||||
/**
|
||||
* TODO describe and cleanup.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function balanceAll(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
@@ -122,13 +120,12 @@ class CurrencyForm
|
||||
/**
|
||||
* TODO cleanup and describe better.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
protected function allCurrencyField(string $name, string $view, $value = null, array $options = null): string
|
||||
{
|
||||
@@ -145,7 +142,7 @@ class CurrencyForm
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
$preFilled = session('preFilled');
|
||||
$key = 'amount_currency_id_' . $name;
|
||||
$sentCurrencyId = isset($preFilled[$key]) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
|
||||
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
@@ -164,7 +161,7 @@ class CurrencyForm
|
||||
}
|
||||
try {
|
||||
$html = prefixView('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
||||
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
}
|
||||
@@ -175,9 +172,9 @@ class CurrencyForm
|
||||
/**
|
||||
* TODO cleanup and describe.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -200,9 +197,9 @@ class CurrencyForm
|
||||
/**
|
||||
* TODO cleanup and describe.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array|null $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user