Skip to content

Firefly III: a personal finances manager

Reformat various code.

James Coled04efb832520
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 077c44de71..4310a18924 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -51,7 +51,7 @@ class Amount
*/
public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string
{
- return $this->formatFlat($format->symbol, (int)$format->decimal_places, $amount, $coloured);
+ return $this->formatFlat($format->symbol, (int) $format->decimal_places, $amount, $coloured);
}
/**
@@ -77,7 +77,7 @@ class Amount
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, $symbol);
$fmt->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $decimalPlaces);
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces);
- $result = $fmt->format((float)$amount);
+ $result = $fmt->format((float) $amount);
if (true === $coloured) {
if ($amount > 0) {
@@ -131,7 +131,7 @@ class Amount
}
$cache->store(config('firefly.default_currency', 'EUR'));
- return (string)config('firefly.default_currency', 'EUR');
+ return (string) config('firefly.default_currency', 'EUR');
}
/**
@@ -164,7 +164,7 @@ class Amount
$currencyPrefStr = $currencyPreference ? $currencyPreference->data : 'EUR';
// at this point the currency preference could be encrypted, if coming from an old version.
- $currencyCode = $this->tryDecrypt((string)$currencyPrefStr);
+ $currencyCode = $this->tryDecrypt((string) $currencyPrefStr);
// could still be json encoded:
/** @var TransactionCurrency|null $currency */
diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.php
index fcfae8c284..c77435c832 100644
--- a/app/Support/Authentication/RemoteUserGuard.php
+++ b/app/Support/Authentication/RemoteUserGuard.php
@@ -81,7 +81,7 @@ class RemoteUserGuard implements Guard
$header = config('auth.guard_email');
if (null !== $header) {
- $emailAddress = (string)(request()->server($header) ?? null);
+ $emailAddress = (string) (request()->server($header) ?? null);
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
if (null !== $emailAddress && null === $preference && $emailAddress !== $userID) {
@@ -96,23 +96,23 @@ class RemoteUserGuard implements Guard
/**
* @inheritDoc
*/
- public function check(): bool
+ public function guest(): bool
{
- return !is_null($this->user());
+ return !$this->check();
}
/**
* @inheritDoc
*/
- public function guest(): bool
+ public function check(): bool
{
- return !$this->check();
+ return !is_null($this->user());
}
/**
* @inheritDoc
*/
- public function id(): ?User
+ public function user(): ?User
{
return $this->user;
}
@@ -120,15 +120,15 @@ class RemoteUserGuard implements Guard
/**
* @inheritDoc
*/
- public function setUser(Authenticatable $user)
+ public function hasUser()
{
- $this->user = $user;
+ // TODO: Implement hasUser() method.
}
/**
* @inheritDoc
*/
- public function user(): ?User
+ public function id(): ?User
{
return $this->user;
}
@@ -136,16 +136,16 @@ class RemoteUserGuard implements Guard
/**
* @inheritDoc
*/
- public function validate(array $credentials = [])
+ public function setUser(Authenticatable $user)
{
- throw new FireflyException('Did not implement RemoteUserGuard::validate()');
+ $this->user = $user;
}
/**
* @inheritDoc
*/
- public function hasUser()
+ public function validate(array $credentials = [])
{
- // TODO: Implement hasUser() method.
+ throw new FireflyException('Did not implement RemoteUserGuard::validate()');
}
}
diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.php
index 4a660214ca..7d152665d2 100644
--- a/app/Support/Authentication/RemoteUserProvider.php
+++ b/app/Support/Authentication/RemoteUserProvider.php
@@ -57,10 +57,10 @@ class RemoteUserProvider implements UserProvider
Log::debug(sprintf('User with email "%s" not found. Will be created.', $identifier));
$user = User::create(
[
- 'blocked' => false,
+ 'blocked' => false,
'blocked_code' => null,
- 'email' => $identifier,
- 'password' => bcrypt(Str::random(64)),
+ 'email' => $identifier,
+ 'password' => bcrypt(Str::random(64)),
]
);
}
diff --git a/app/Support/Binder/CLIToken.php b/app/Support/Binder/CLIToken.php
index 4e14c59d0f..7877c20280 100644
--- a/app/Support/Binder/CLIToken.php
+++ b/app/Support/Binder/CLIToken.php
@@ -49,7 +49,7 @@ class CLIToken implements BinderInterface
$users = $repository->all();
// check for static token
- if ($value === config('firefly.static_cron_token') && 32 === strlen((string)config('firefly.static_cron_token'))) {
+ if ($value === config('firefly.static_cron_token') && 32 === strlen((string) config('firefly.static_cron_token'))) {
return $value;
}
diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php
index c5440988ee..daa29e434e 100644
--- a/app/Support/Binder/TagList.php
+++ b/app/Support/Binder/TagList.php
@@ -69,7 +69,7 @@ class TagList implements BinderInterface
if (in_array(strtolower($tag->tag), $list, true)) {
return true;
}
- if (in_array((string)$tag->id, $list, true)) {
+ if (in_array((string) $tag->id, $list, true)) {
return true;
}
diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.php
index cbf631ce26..42e33edd0e 100644
--- a/app/Support/Binder/TagOrId.php
+++ b/app/Support/Binder/TagOrId.php
@@ -48,7 +48,7 @@ class TagOrId implements BinderInterface
$result = $repository->findByTag($value);
if (null === $result) {
- $result = $repository->find((int)$value);
+ $result = $repository->find((int) $value);
}
if (null !== $result) {
return $result;
diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.php
index 0d95c386a5..37a1db4cb3 100644
--- a/app/Support/CacheProperties.php
+++ b/app/Support/CacheProperties.php
@@ -95,7 +95,7 @@ class CacheProperties
$content .= json_encode($property, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
// @ignoreException
- $content .= hash('sha256', (string)time());
+ $content .= hash('sha256', (string) time());
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php
index 8e3468e400..1315677027 100644
--- a/app/Support/Chart/Budget/FrontpageChartGenerator.php
+++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php
@@ -64,9 +64,9 @@ class FrontpageChartGenerator
{
$budgets = $this->budgetRepository->getActiveBudgets();
$data = [
- ['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
- ['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
- ['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string) trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string) trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],
+ ['label' => (string) trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],
];
// loop al budgets:
@@ -158,7 +158,7 @@ class FrontpageChartGenerator
/** @var array $entry */
foreach ($spent as $entry) {
// only spent the entry where the entry's currency matches the budget limit's currency
- if ($entry['currency_id'] === (int)$limit->transaction_currency_id) {
+ if ($entry['currency_id'] === (int) $limit->transaction_currency_id) {
$data = $this->processRow($data, $budget, $limit, $entry);
}
}
@@ -229,6 +229,6 @@ class FrontpageChartGenerator
$this->opsRepository->setUser($user);
$locale = app('steam')->getLocale();
- $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);
+ $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
}
}
diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.php
index 9aeb91d2de..d12cf4c633 100644
--- a/app/Support/Chart/Category/FrontpageChartGenerator.php
+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php
@@ -114,8 +114,8 @@ class FrontpageChartGenerator
$tempData[] = [
'name' => $category->name,
'sum' => $currency['sum'],
- 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places']),
- 'currency_id' => (int)$currency['currency_id'],
+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places']),
+ 'currency_id' => (int) $currency['currency_id'],
];
}
@@ -127,7 +127,7 @@ class FrontpageChartGenerator
*/
private function addCurrency(array $currency): void
{
- $currencyId = (int)$currency['currency_id'];
+ $currencyId = (int) $currency['currency_id'];
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? [
'currency_id' => $currencyId,
@@ -152,8 +152,8 @@ class FrontpageChartGenerator
$tempData[] = [
'name' => trans('firefly.no_category'),
'sum' => $currency['sum'],
- 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places'] ?? 2),
- 'currency_id' => (int)$currency['currency_id'],
+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places'] ?? 2),
+ 'currency_id' => (int) $currency['currency_id'],
];
}
@@ -175,7 +175,7 @@ class FrontpageChartGenerator
foreach ($this->currencies as $currencyId => $currency) {
$key = sprintf('spent-%d', $currencyId);
$return[$key] = [
- 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currency['currency_name']),
+ 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currency['currency_name']),
'type' => 'bar',
'currency_symbol' => $currency['currency_symbol'],
'entries' => $names,
diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php
index ffd0a4ce9d..867cb3f337 100644
--- a/app/Support/Chart/Category/WholePeriodChartGenerator.php
+++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php
@@ -77,14 +77,14 @@ class WholePeriodChartGenerator
$code = $currency['currency_code'];
$name = $currency['currency_name'];
$chartData[sprintf('spent-in-%s', $code)] = [
- 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $name]),
+ 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $name]),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
];
$chartData[sprintf('earned-in-%s', $code)] = [
- 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $name]),
+ 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $name]),
'entries' => [],
'type' => 'bar',
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
@@ -105,8 +105,8 @@ class WholePeriodChartGenerator
$earnedInfoKey = sprintf('earned-in-%s', $code);
$spentAmount = $spent[$key][$currencyId]['sum'] ?? '0';
$earnedAmount = $earned[$key][$currencyId]['sum'] ?? '0';
- $chartData[$spentInfoKey]['entries'][$label] = round((float)$spentAmount, $currency['currency_decimal_places']);
- $chartData[$earnedInfoKey]['entries'][$label] = round((float)$earnedAmount, $currency['currency_decimal_places']);
+ $chartData[$spentInfoKey]['entries'][$label] = round((float) $spentAmount, $currency['currency_decimal_places']);
+ $chartData[$earnedInfoKey]['entries'][$label] = round((float) $earnedAmount, $currency['currency_decimal_places']);
}
$current = app('navigation')->addPeriod($current, $step, 0);
}
diff --git a/app/Support/Cronjobs/AbstractCronjob.php b/app/Support/Cronjobs/AbstractCronjob.php
index 1783889cb9..1625a45726 100644
--- a/app/Support/Cronjobs/AbstractCronjob.php
+++ b/app/Support/Cronjobs/AbstractCronjob.php
@@ -32,10 +32,10 @@ use Carbon\Carbon;
*/
abstract class AbstractCronjob
{
- public bool $jobErrored;
- public bool $jobFired;
- public bool $jobSucceeded;
- public ?string $message;
+ public bool $jobErrored;
+ public bool $jobFired;
+ public bool $jobSucceeded;
+ public ?string $message;
public int $timeBetweenRuns = 43200;
protected Carbon $date;
protected bool $force;
diff --git a/app/Support/Cronjobs/AutoBudgetCronjob.php b/app/Support/Cronjobs/AutoBudgetCronjob.php
index ada8681278..615d5b5789 100644
--- a/app/Support/Cronjobs/AutoBudgetCronjob.php
+++ b/app/Support/Cronjobs/AutoBudgetCronjob.php
@@ -42,7 +42,7 @@ class AutoBudgetCronjob extends AbstractCronjob
{
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_ab_job', 0);
- $lastTime = (int)$config->data;
+ $lastTime = (int) $config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
if (0 === $lastTime) {
@@ -89,7 +89,7 @@ class AutoBudgetCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Auto-budget cron job fired successfully.';
- app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));
+ app('fireflyconfig')->set('last_ab_job', (int) $this->date->format('U'));
Log::info('Done with auto budget cron job task.');
}
}
diff --git a/app/Support/Cronjobs/BillWarningCronjob.php b/app/Support/Cronjobs/BillWarningCronjob.php
index f91fa5f1a3..b0238e7756 100644
--- a/app/Support/Cronjobs/BillWarningCronjob.php
+++ b/app/Support/Cronjobs/BillWarningCronjob.php
@@ -42,7 +42,7 @@ class BillWarningCronjob extends AbstractCronjob
Log::debug(sprintf('Now in %s', __METHOD__));
/** @var Configuration $config */
$config = app('fireflyconfig')->get('last_bw_job', 0);
- $lastTime = (int)$config->data;
+ $lastTime = (int) $config->data;
$diff = time() - $lastTime;
$diffForHumans = Carbon::now()->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);
@@ -95,8 +95,8 @@ class BillWarningCronjob extends AbstractCronjob
$this->jobSucceeded = true;
$this->message = 'Bill warning cron job fired successfully.';
- app('fireflyconfig')->set('last_bw_job', (int)$this->date->format('U'));
- Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));
+ app('fireflyconfig')->set('last_bw_job', (int) $this->date->format('U'));
+ Log::info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));
Log::info('Done with bill warning cron job task.');
}
}
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 73651c9fd9..8a90790dda 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -214,7 +214,7 @@ class ExpandedForm
$fields = ['title', 'name', 'description'];
/** @var Eloquent $entry */
foreach ($set as $entry) {
- $entryId = (int)$entry->id; // @phpstan-ignore-line
+ $entryId = (int) $entry->id; // @phpstan-ignore-line
$current = $entry->toArray();
$title = null;
foreach ($fields as $field) {
diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php
index eb9b9c0ce2..c7aeeadac0 100644
--- a/app/Support/FireflyConfig.php
+++ b/app/Support/FireflyConfig.php
@@ -69,7 +69,7 @@ class FireflyConfig
try {
/** @var Configuration|null $config */
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
- } catch (QueryException | Exception $e) { // @phpstan-ignore-line
+ } catch (QueryException|Exception $e) { // @phpstan-ignore-line
throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage()));
}
@@ -96,7 +96,7 @@ class FireflyConfig
{
try {
$config = Configuration::whereName($name)->whereNull('deleted_at')->first();
- } catch (QueryException | Exception $e) { // @phpstan-ignore-line
+ } catch (QueryException|Exception $e) { // @phpstan-ignore-line
$item = new Configuration;
$item->name = $name;
$item->data = $value;
diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.php
index c51d2770dc..740a2c6896 100644
--- a/app/Support/Form/AccountForm.php
+++ b/app/Support/Form/AccountForm.php
@@ -56,8 +56,8 @@ class AccountForm
$repository = $this->getAccountRepository();
$grouped = $this->getAccountsGrouped($types, $repository);
$cash = $repository->getCashAccount();
- $key = (string)trans('firefly.cash_account_type');
- $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));
+ $key = (string) trans('firefly.cash_account_type');
+ $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));
return $this->select($name, $grouped, $value, $options);
}
@@ -73,7 +73,7 @@ class AccountForm
/** @var Account $account */
foreach ($accountList as $account) {
- $role = (string)$repository->getMetaValue($account, 'account_role');
+ $role = (string) $repository->getMetaValue($account, 'account_role');
if (in_array($account->accountType->type, $liabilityTypes, true)) {
$role = sprintf('l_%s', $account->accountType->type);
} elseif ('' === $role) {
@@ -85,7 +85,7 @@ class AccountForm
$role = 'no_account_type';
}
}
- $key = (string)trans(sprintf('firefly.opt_group_%s', $role));
+ $key = (string) trans(sprintf('firefly.opt_group_%s', $role));
$grouped[$key][$account->id] = $account->name;
}
@@ -108,8 +108,8 @@ class AccountForm
$grouped = $this->getAccountsGrouped($types, $repository);
$cash = $repository->getCashAccount();
- $key = (string)trans('firefly.cash_account_type');
- $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));
+ $key = (string) trans('firefly.cash_account_type');
+ $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));
return $this->select($name, $grouped, $value, $options);
}
diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.php
index 619ed23cf5..042478a958 100644
--- a/app/Support/Form/CurrencyForm.php
+++ b/app/Support/Form/CurrencyForm.php
@@ -77,7 +77,7 @@ class CurrencyForm
$preFilled = [];
}
$key = 'amount_currency_id_' . $name;
- $sentCurrencyId = array_key_exists($key, $preFilled) ? (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));
@@ -92,7 +92,7 @@ class CurrencyForm
// make sure value is formatted nicely:
if (null !== $value && '' !== $value) {
- $value = round((float)$value, $defaultCurrency->decimal_places);
+ $value = round((float) $value, $defaultCurrency->decimal_places);
}
try {
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
@@ -146,7 +146,7 @@ class CurrencyForm
$preFilled = [];
}
$key = 'amount_currency_id_' . $name;
- $sentCurrencyId = array_key_exists($key, $preFilled) ? (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));
@@ -161,7 +161,7 @@ class CurrencyForm
// make sure value is formatted nicely:
if (null !== $value && '' !== $value) {
- $value = round((float)$value, $defaultCurrency->decimal_places);
+ $value = round((float) $value, $defaultCurrency->decimal_places);
}
try {
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
@@ -215,7 +215,7 @@ class CurrencyForm
// get all currencies:
$list = $currencyRepos->get();
$array = [
- 0 => (string)trans('firefly.no_currency'),
+ 0 => (string) trans('firefly.no_currency'),
];
/** @var TransactionCurrency $currency */
foreach ($list as $currency) {
diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.php
index df9f3cd928..0abf922be0 100644
--- a/app/Support/Form/FormSupport.php
+++ b/app/Support/Form/FormSupport.php
@@ -76,7 +76,7 @@ trait FormSupport
}
$name = str_replace('[]', '', $name);
- return (string)trans('form.' . $name);
+ return (string) trans('form.' . $name);
}
/**
diff --git a/app/Support/Form/PiggyBankForm.php b/app/Support/Form/PiggyBankForm.php
index e4165cb49b..3d836661be 100644
--- a/app/Support/Form/PiggyBankForm.php
+++ b/app/Support/Form/PiggyBankForm.php
@@ -50,7 +50,7 @@ class PiggyBankForm
/** @var PiggyBankRepositoryInterface $repository */
$repository = app(PiggyBankRepositoryInterface::class);
$piggyBanks = $repository->getPiggyBanksWithAmount();
- $title = (string)trans('firefly.default_group_title_name');
+ $title = (string) trans('firefly.default_group_title_name');
$array = [];
$subList = [
0 => [
@@ -58,7 +58,7 @@ class PiggyBankForm
'title' => $title,
],
'piggies' => [
- (string)trans('firefly.none_in_select_list'),
+ (string) trans('firefly.none_in_select_list'),
],
],
];
diff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.php
index a757d5b983..87f0b29ff9 100644
--- a/app/Support/Form/RuleForm.php
+++ b/app/Support/Form/RuleForm.php
@@ -76,11 +76,11 @@ class RuleForm
// get all currencies:
$list = $groupRepos->get();
$array = [
- 0 => (string)trans('firefly.none_in_select_list'),
+ 0 => (string) trans('firefly.none_in_select_list'),
];
/** @var RuleGroup $group */
foreach ($list as $group) {
- if (array_key_exists('hidden', $options) && (int)$options['hidden'] !== $group->id) {
+ if (array_key_exists('hidden', $options) && (int) $options['hidden'] !== $group->id) {
$array[$group->id] = $group->title;
}
}
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index 644d5d39a7..9eb07bbe8f 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -123,7 +123,7 @@ trait AugumentData
$return = [];
foreach ($accountIds as $combinedId) {
$parts = explode('-', $combinedId);
- $accountId = (int)$parts[0];
+ $accountId = (int) $parts[0];
if (array_key_exists($accountId, $grouped)) {
$return[$accountId] = $grouped[$accountId][0]['name'];
}
@@ -152,7 +152,7 @@ trait AugumentData
$return[$budgetId] = $grouped[$budgetId][0]['name'];
}
}
- $return[0] = (string)trans('firefly.no_budget');
+ $return[0] = (string) trans('firefly.no_budget');
return $return;
}
@@ -173,12 +173,12 @@ trait AugumentData
$return = [];
foreach ($categoryIds as $combinedId) {
$parts = explode('-', $combinedId);
- $categoryId = (int)$parts[0];
+ $categoryId = (int) $parts[0];
if (array_key_exists($categoryId, $grouped)) {
$return[$categoryId] = $grouped[$categoryId][0]['name'];
}
}
- $return[0] = (string)trans('firefly.no_category');
+ $return[0] = (string) trans('firefly.no_category');
return $return;
}
@@ -222,7 +222,7 @@ trait AugumentData
$currentStart = clone $entry->start_date;
$currentEnd = clone $entry->end_date;
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
- $spent = $expenses[(int)$currency->id]['sum'] ?? '0';
+ $spent = $expenses[(int) $currency->id]['sum'] ?? '0';
$entry->spent = $spent;
$limits->push($entry);
@@ -285,7 +285,7 @@ trait AugumentData
];
// loop to support multi currency
foreach ($journals as $journal) {
- $currencyId = (int)$journal['currency_id'];
+ $currencyId = (int) $journal['currency_id'];
// if not set, set to zero:
if (!array_key_exists($currencyId, $sum['per_currency'])) {
diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php
index 7653ff38fc..0db3129191 100644
--- a/app/Support/Http/Controllers/ChartGeneration.php
+++ b/app/Support/Http/Controllers/ChartGeneration.php
@@ -77,7 +77,7 @@ trait ChartGeneration
/** @var Account $account */
foreach ($accounts as $account) {
// See reference nr. 33
- $currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id'));
+ $currency = $repository->find((int) $accountRepos->getMetaValue($account, 'currency_id'));
if (null === $currency) {
$currency = $default;
}
@@ -92,7 +92,7 @@ trait ChartGeneration
$previous = array_values($range)[0];
while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d');
- $label = trim($currentStart->isoFormat((string)trans('config.month_and_day_js', [], $locale)));
+ $label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));
$balance = $range[$format] ?? $previous;
$previous = $balance;
$currentStart->addDay();
diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.php
index 039d5c853c..4ec6aec618 100644
--- a/app/Support/Http/Controllers/CreateStuff.php
+++ b/app/Support/Http/Controllers/CreateStuff.php
@@ -83,7 +83,7 @@ trait CreateStuff
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$assetAccount = [
- 'name' => (string)trans('firefly.cash_wallet', [], $language),
+ 'name' => (string) trans('firefly.cash_wallet', [], $language),
'iban' => null,
'account_type_name' => 'asset',
'virtual_balance' => 0,
@@ -150,7 +150,7 @@ trait CreateStuff
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$savingsAccount = [
- 'name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
+ 'name' => (string) trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),
'iban' => null,
'account_type_name' => 'asset',
'account_type_id' => null,
diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php
index a9567e8500..c28110864f 100644
--- a/app/Support/Http/Controllers/GetConfigurationData.php
+++ b/app/Support/Http/Controllers/GetConfigurationData.php
@@ -52,7 +52,7 @@ trait GetConfigurationData
E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',
];
- return $array[$value] ?? (string)$value;
+ return $array[$value] ?? (string) $value;
}
/**
@@ -72,7 +72,7 @@ trait GetConfigurationData
$currentStep = $options;
// get the text:
- $currentStep['intro'] = (string)trans('intro.' . $route . '_' . $key);
+ $currentStep['intro'] = (string) trans('intro.' . $route . '_' . $key);
// save in array:
$steps[] = $currentStep;
@@ -91,7 +91,7 @@ trait GetConfigurationData
*/
protected function getDateRangeConfig(): array // get configuration + get preferences.
{
- $viewRange = (string)app('preferences')->get('viewRange', '1M')->data;
+ $viewRange = (string) app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
$start = session('start');
/** @var Carbon $end */
@@ -132,31 +132,31 @@ trait GetConfigurationData
/** @var Carbon $todayEnd */
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);
if ($todayStart->ne($start) || $todayEnd->ne($end)) {
- $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];
+ $ranges[ucfirst((string) trans('firefly.today'))] = [$todayStart, $todayEnd];
}
// last seven days:
$seven = Carbon::now()->subDays(7);
- $index = (string)trans('firefly.last_seven_days');
+ $index = (string) trans('firefly.last_seven_days');
$ranges[$index] = [$seven, new Carbon];
// last 30 days:
$thirty = Carbon::now()->subDays(30);
- $index = (string)trans('firefly.last_thirty_days');
+ $index = (string) trans('firefly.last_thirty_days');
$ranges[$index] = [$thirty, new Carbon];
// everything
- $index = (string)trans('firefly.everything');
+ $index = (string) trans('firefly.everything');
$ranges[$index] = [$first, new Carbon];
return [
'title' => $title,
'configuration' => [
- 'apply' => (string)trans('firefly.apply'),
- 'cancel' => (string)trans('firefly.cancel'),
- 'from' => (string)trans('firefly.from'),
- 'to' => (string)trans('firefly.to'),
- 'customRange' => (string)trans('firefly.customRange'),
+ 'apply' => (string) trans('firefly.apply'),
+ 'cancel' => (string) trans('firefly.cancel'),
+ 'from' => (string) trans('firefly.from'),
+ 'to' => (string) trans('firefly.to'),
+ 'customRange' => (string) trans('firefly.customRange'),
'start' => $start->format('Y-m-d'),
'end' => $end->format('Y-m-d'),
'ranges' => $ranges,
@@ -187,7 +187,7 @@ trait GetConfigurationData
$currentStep = $options;
// get the text:
- $currentStep['intro'] = (string)trans('intro.' . $route . '_' . $specificPage . '_' . $key);
+ $currentStep['intro'] = (string) trans('intro.' . $route . '_' . $specificPage . '_' . $key);
// save in array:
$steps[] = $currentStep;
@@ -205,7 +205,7 @@ trait GetConfigurationData
protected function verifyRecurringCronJob(): void
{
$config = app('fireflyconfig')->get('last_rt_job', 0);
- $lastTime = (int)$config->data;
+ $lastTime = (int) $config->data;
$now = time();
Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config->data, $now));
if (0 === $lastTime) {
diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.php
index 30d61b7fa2..9164a6098f 100644
--- a/app/Support/Http/Controllers/ModelInformation.php
+++ b/app/Support/Http/Controllers/ModelInformation.php
@@ -83,9 +83,9 @@ trait ModelInformation
$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);
/** @noinspection NullPointerExceptionInspection */
$liabilityTypes = [
- $debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
- $loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
- $mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
+ $debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::DEBT)),
+ $loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::LOAN)),
+ $mortgage->id => (string) trans(sprintf('firefly.account_type_%s', AccountType::MORTGAGE)),
];
asort($liabilityTypes);
@@ -100,7 +100,7 @@ trait ModelInformation
{
$roles = [];
foreach (config('firefly.accountRoles') as $role) {
- $roles[$role] = (string)trans(sprintf('firefly.account_role_%s', $role));
+ $roles[$role] = (string) trans(sprintf('firefly.account_role_%s', $role));
}
return $roles;
@@ -121,7 +121,7 @@ trait ModelInformation
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -130,8 +130,8 @@ trait ModelInformation
$billTriggers = ['currency_is', 'amount_more', 'amount_less', 'description_contains'];
$values = [
$bill->transactionCurrency()->first()->name,
- round((float)$bill->amount_min, 24),
- round((float)$bill->amount_max, 24),
+ round((float) $bill->amount_min, 24),
+ round((float) $bill->amount_max, 24),
$bill->name,
];
foreach ($billTriggers as $index => $trigger) {
@@ -173,7 +173,7 @@ trait ModelInformation
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.php
index 8286ead5ae..b15829ca0d 100644
--- a/app/Support/Http/Controllers/PeriodOverview.php
+++ b/app/Support/Http/Controllers/PeriodOverview.php
@@ -183,7 +183,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
- if ($account->id === (int)$journal['source_account_id']) {
+ if ($account->id === (int) $journal['source_account_id']) {
$return[] = $journal;
}
}
@@ -205,7 +205,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
- if ($account->id === (int)$journal['destination_account_id']) {
+ if ($account->id === (int) $journal['destination_account_id']) {
$return[] = $journal;
}
}
@@ -224,7 +224,7 @@ trait PeriodOverview
$return = [];
/** @var array $journal */
foreach ($journals as $journal) {
- $currencyId = (int)$journal['currency_id'];
+ $currencyId = (int) $journal['currency_id'];
$foreignCurrencyId = $journal['foreign_currency_id'];
if (!array_key_exists($currencyId, $return)) {
$return[$currencyId] = [
@@ -245,7 +245,7 @@ trait PeriodOverview
$return[$foreignCurrencyId] = [
'amount' => '0',
'count' => 0,
- 'currency_id' => (int)$foreignCurrencyId,
+ 'currency_id' => (int) $foreignCurrencyId,
'currency_name' => $journal['foreign_currency_name'],
'currency_code' => $journal['foreign_currency_code'],
'currency_symbol' => $journal['foreign_currency_symbol'],
diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php
index 7d3d56da0f..3990c7bbc2 100644
--- a/app/Support/Http/Controllers/RenderPartialViews.php
+++ b/app/Support/Http/Controllers/RenderPartialViews.php
@@ -59,10 +59,10 @@ trait RenderPartialViews
/** @var BudgetRepositoryInterface $budgetRepository */
$budgetRepository = app(BudgetRepositoryInterface::class);
- $budget = $budgetRepository->find((int)$attributes['budgetId']);
+ $budget = $budgetRepository->find((int) $attributes['budgetId']);
$accountRepos = app(AccountRepositoryInterface::class);
- $account = $accountRepos->find((int)$attributes['accountId']);
+ $account = $accountRepos->find((int) $attributes['accountId']);
$journals = $popupHelper->balanceForBudget($budget, $account, $attributes);
@@ -112,7 +112,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
- $budget = $budgetRepository->find((int)$attributes['budgetId']);
+ $budget = $budgetRepository->find((int) $attributes['budgetId']);
if (null === $budget) {
$budget = new Budget;
}
@@ -142,7 +142,7 @@ trait RenderPartialViews
/** @var CategoryRepositoryInterface $categoryRepository */
$categoryRepository = app(CategoryRepositoryInterface::class);
- $category = $categoryRepository->find((int)$attributes['categoryId']);
+ $category = $categoryRepository->find((int) $attributes['categoryId']);
$journals = $popupHelper->byCategory($category, $attributes);
try {
@@ -232,7 +232,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
- $account = $accountRepository->find((int)$attributes['accountId']);
+ $account = $accountRepository->find((int) $attributes['accountId']);
if (null === $account) {
return 'This is an unknown account. Apologies.';
@@ -304,7 +304,7 @@ trait RenderPartialViews
foreach ($operators as $key => $operator) {
if ('user_action' !== $key && false === $operator['alias']) {
- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));
+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
}
}
asort($triggers);
@@ -354,7 +354,7 @@ trait RenderPartialViews
/** @var PopupReportInterface $popupHelper */
$popupHelper = app(PopupReportInterface::class);
- $account = $accountRepository->find((int)$attributes['accountId']);
+ $account = $accountRepository->find((int) $attributes['accountId']);
if (null === $account) {
return 'This is an unknown category. Apologies.';
diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.php
index f019723da1..8a36067eda 100644
--- a/app/Support/Http/Controllers/RequestInformation.php
+++ b/app/Support/Http/Controllers/RequestInformation.php
@@ -73,7 +73,7 @@ trait RequestInformation
$triggers[] = [
'type' => $triggerInfo['type'] ?? '',
'value' => $triggerInfo['value'] ?? '',
- 'stop_processing' => 1 === (int)($triggerInfo['stop_processing'] ?? '0'),
+ 'stop_processing' => 1 === (int) ($triggerInfo['stop_processing'] ?? '0'),
];
}
}
@@ -198,11 +198,11 @@ trait RequestInformation
final protected function validatePassword(User $user, string $current, string $new): bool //get request info
{
if (!Hash::check($current, $user->password)) {
- throw new ValidationException((string)trans('firefly.invalid_current_password'));
+ throw new ValidationException((string) trans('firefly.invalid_current_password'));
}
if ($current === $new) {
- throw new ValidationException((string)trans('firefly.should_change'));
+ throw new ValidationException((string) trans('firefly.should_change'));
}
return true;
diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.php
index 6d5e41cbe8..b04870b01b 100644
--- a/app/Support/ParseDateString.php
+++ b/app/Support/ParseDateString.php
@@ -114,7 +114,7 @@ class ParseDateString
return new Carbon('1984-09-17');
}
// maybe a year, nothing else?
- if (4 === strlen($date) && is_numeric($date) && (int)$date > 1000 && (int)$date <= 3000) {
+ if (4 === strlen($date) && is_numeric($date) && (int) $date > 1000 && (int) $date <= 3000) {
return new Carbon(sprintf('%d-01-01', $date));
}
@@ -194,7 +194,7 @@ class ParseDateString
}
$direction = str_starts_with($part, '+') ? 1 : 0;
$period = $part[strlen($part) - 1];
- $number = (int)substr($part, 1, -1);
+ $number = (int) substr($part, 1, -1);
if (!array_key_exists($period, $functions[$direction])) {
Log::error(sprintf('No method for direction %d and period "%s".', $direction, $period));
continue;
diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php
index 4931d578a7..cdf4c1226c 100644
--- a/app/Support/Report/Budget/BudgetReportGenerator.php
+++ b/app/Support/Report/Budget/BudgetReportGenerator.php
@@ -110,8 +110,8 @@ class BudgetReportGenerator
*/
private function processBudgetExpenses(array $expenses, array $budget): void
{
- $budgetId = (int)$budget['id'];
- $currencyId = (int)$expenses['currency_id'];
+ $budgetId = (int) $budget['id'];
+ $currencyId = (int) $expenses['currency_id'];
foreach ($budget['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id'];
@@ -167,7 +167,7 @@ class BudgetReportGenerator
*/
private function processBudget(Budget $budget): void
{
- $budgetId = (int)$budget->id;
+ $budgetId = (int) $budget->id;
$this->report['budgets'][$budgetId] = $this->report['budgets'][$budgetId] ?? [
'budget_id' => $budgetId,
'budget_name' => $budget->name,
@@ -191,10 +191,10 @@ class BudgetReportGenerator
*/
private function processLimit(Budget $budget, BudgetLimit $limit): void
{
- $budgetId = (int)$budget->id;
- $limitId = (int)$limit->id;
+ $budgetId = (int) $budget->id;
+ $limitId = (int) $limit->id;
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
- $currencyId = (int)$limitCurrency->id;
+ $currencyId = (int) $limitCurrency->id;
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget]));
$spent = $expenses[$currencyId]['sum'] ?? '0';
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
@@ -253,7 +253,7 @@ class BudgetReportGenerator
foreach ($noBudget as $noBudgetEntry) {
// currency information:
- $nbCurrencyId = (int)($noBudgetEntry['currency_id'] ?? $this->currency->id);
+ $nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id);
$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code;
$nbCurrencyName = $noBudgetEntry['currency_name'] ?? $this->currency->name;
$nbCurrencySymbol = $noBudgetEntry['currency_symbol'] ?? $this->currency->symbol;
@@ -298,9 +298,9 @@ class BudgetReportGenerator
// make percentages based on total amount.
foreach ($this->report['budgets'] as $budgetId => $data) {
foreach ($data['budget_limits'] as $limitId => $entry) {
- $budgetId = (int)$budgetId;
- $limitId = (int)$limitId;
- $currencyId = (int)$entry['currency_id'];
+ $budgetId = (int) $budgetId;
+ $limitId = (int) $limitId;
+ $currencyId = (int) $entry['currency_id'];
$spent = $entry['spent'];
$totalSpent = $this->report['sums'][$currencyId]['spent'] ?? '0';
$spentPct = '0';
@@ -309,10 +309,10 @@ class BudgetReportGenerator
$budgetedPct = '0';
if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {
- $spentPct = round((float)bcmul(bcdiv($spent, $totalSpent), '100'));
+ $spentPct = round((float) bcmul(bcdiv($spent, $totalSpent), '100'));
}
if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {
- $budgetedPct = round((float)bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
+ $budgetedPct = round((float) bcmul(bcdiv($budgeted, $totalBudgeted), '100'));
}
$this->report['sums'][$currencyId]['budgeted'] = $this->report['sums'][$currencyId]['budgeted'] ?? '0';
$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;
diff --git a/app/Support/Report/Category/CategoryReportGenerator.php b/app/Support/Report/Category/CategoryReportGenerator.php
index 5d6c25d0a6..efd064d6b3 100644
--- a/app/Support/Report/Category/CategoryReportGenerator.php
+++ b/app/Support/Report/Category/CategoryReportGenerator.php
@@ -64,12 +64,12 @@ class CategoryReportGenerator
*/
public function operations(): void
{
- $earnedWith = $this->opsRepository->listIncome($this->start, $this->end, $this->accounts);
- $spentWith = $this->opsRepository->listExpenses($this->start, $this->end, $this->accounts);
+ $earnedWith = $this->opsRepository->listIncome($this->start, $this->end, $this->accounts);
+ $spentWith = $this->opsRepository->listExpenses($this->start, $this->end, $this->accounts);
// also transferred out and transferred into these accounts in this category:
- $transferredIn = $this->opsRepository->listTransferredIn($this->start, $this->end, $this->accounts);
- $transferredOut = $this->opsRepository->listTransferredOut($this->start, $this->end, $this->accounts);
+ $transferredIn = $this->opsRepository->listTransferredIn($this->start, $this->end, $this->accounts);
+ $transferredOut = $this->opsRepository->listTransferredOut($this->start, $this->end, $this->accounts);
$earnedWithout = $this->noCatRepository->listIncome($this->start, $this->end, $this->accounts);
$spentWithout = $this->noCatRepository->listExpenses($this->start, $this->end, $this->accounts);
diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
index 87d1f78ee7..d5160b32ef 100644
--- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
+++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php
@@ -72,7 +72,7 @@ trait CalculateRangeOccurrences
{
$return = [];
$attempts = 0;
- $dayOfMonth = (int)$moment;
+ $dayOfMonth = (int) $moment;
if ($start->day > $dayOfMonth) {
// day has passed already, add a month.
$start->addMonth();
@@ -140,7 +140,7 @@ trait CalculateRangeOccurrences
Log::debug('Rep is weekly.');
// monday = 1
// sunday = 7
- $dayOfWeek = (int)$moment;
+ $dayOfWeek = (int) $moment;
Log::debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso));
if ($start->dayOfWeekIso > $dayOfWeek) {
// day has already passed this week, add one week:
diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.php
index 32af55143f..04afa7dd81 100644
--- a/app/Support/Repositories/Recurring/FiltersWeekends.php
+++ b/app/Support/Repositories/Recurring/FiltersWeekends.php
@@ -47,7 +47,7 @@ trait FiltersWeekends
protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
- if ((int)$repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
+ if ((int) $repetition->weekend === RecurrenceRepetition::WEEKEND_DO_NOTHING) {
Log::debug('Repetition will not be filtered on weekend days.');
return $dates;
diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.php
index 4f05f031e7..77b7e7e3e1 100644
--- a/app/Support/Request/AppendsLocationData.php
+++ b/app/Support/Request/AppendsLocationData.php
@@ -30,6 +30,15 @@ use Log;
*/
trait AppendsLocationData
{
+ /**
+ * Abstract method.
+ *
+ * @param $key
+ *
+ * @return bool
+ */
+ abstract public function has($key);
+
/**
* Read the submitted Request data and add new or updated Location data to the array.
*
@@ -148,25 +157,6 @@ trait AppendsLocationData
return false;
}
- /**
- * Abstract method stolen from "InteractsWithInput".
- *
- * @param null $key
- * @param bool $default
- *
- * @return mixed
- */
- abstract public function boolean($key = null, $default = false);
-
- /**
- * Abstract method.
- *
- * @param $key
- *
- * @return bool
- */
- abstract public function has($key);
-
/**
* Abstract method.
*
@@ -183,6 +173,16 @@ trait AppendsLocationData
*/
abstract public function routeIs(...$patterns);
+ /**
+ * Abstract method stolen from "InteractsWithInput".
+ *
+ * @param null $key
+ * @param bool $default
+ *
+ * @return mixed
+ */
+ abstract public function boolean($key = null, $default = false);
+
/**
* @param string|null $prefix
*
diff --git a/app/Support/Request/GetRecurrenceData.php b/app/Support/Request/GetRecurrenceData.php
index 9b8ffe0dc5..38602e28f2 100644
--- a/app/Support/Request/GetRecurrenceData.php
+++ b/app/Support/Request/GetRecurrenceData.php
@@ -42,7 +42,7 @@ trait GetRecurrenceData
$return['amount'] = $transaction['amount'];
}
if (array_key_exists('currency_id', $transaction)) {
- $return['currency_id'] = (int)$transaction['currency_id'];
+ $return['currency_id'] = (int) $transaction['currency_id'];
}
if (array_key_exists('currency_code', $transaction)) {
$return['currency_code'] = $transaction['currency_code'];
@@ -53,17 +53,17 @@ trait GetRecurrenceData
$return['foreign_amount'] = $transaction['foreign_amount'];
}
if (array_key_exists('foreign_currency_id', $transaction)) {
- $return['foreign_currency_id'] = (int)$transaction['foreign_currency_id'];
+ $return['foreign_currency_id'] = (int) $transaction['foreign_currency_id'];
}
if (array_key_exists('foreign_currency_code', $transaction)) {
$return['foreign_currency_code'] = $transaction['foreign_currency_code'];
}
// source + dest
if (array_key_exists('source_id', $transaction)) {
- $return['source_id'] = (int)$transaction['source_id'];
+ $return['source_id'] = (int) $transaction['source_id'];
}
if (array_key_exists('destination_id', $transaction)) {
- $return['destination_id'] = (int)$transaction['destination_id'];
+ $return['destination_id'] = (int) $transaction['destination_id'];
}
// description
if (array_key_exists('description', $transaction)) {
@@ -71,17 +71,17 @@ trait GetRecurrenceData
}
if (array_key_exists('piggy_bank_id', $transaction)) {
- $return['piggy_bank_id'] = (int)$transaction['piggy_bank_id'];
+ $return['piggy_bank_id'] = (int) $transaction['piggy_bank_id'];
}
if (array_key_exists('tags', $transaction)) {
$return['tags'] = $transaction['tags'];
}
if (array_key_exists('budget_id', $transaction)) {
- $return['budget_id'] = (int)$transaction['budget_id'];
+ $return['budget_id'] = (int) $transaction['budget_id'];
}
if (array_key_exists('category_id', $transaction)) {
- $return['category_id'] = (int)$transaction['category_id'];
+ $return['category_id'] = (int) $transaction['category_id'];
}
return $return;
diff --git a/app/Support/System/GeneratesInstallationId.php b/app/Support/System/GeneratesInstallationId.php
index 417a2672f3..f03dc048c5 100644
--- a/app/Support/System/GeneratesInstallationId.php
+++ b/app/Support/System/GeneratesInstallationId.php
@@ -53,7 +53,7 @@ trait GeneratesInstallationId
if (null === $config) {
$uuid4 = Uuid::uuid4();
- $uniqueId = (string)$uuid4;
+ $uniqueId = (string) $uuid4;
Log::info(sprintf('Created Firefly III installation ID %s', $uniqueId));
app('fireflyconfig')->set('installation_id', $uniqueId);
}
diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php
index 97e0dcc8d5..76d75ee230 100644
--- a/app/Support/System/OAuthKeys.php
+++ b/app/Support/System/OAuthKeys.php
@@ -72,9 +72,9 @@ class OAuthKeys
// better check if keys are in the database:
if (app('fireflyconfig')->has(self::PRIVATE_KEY) && app('fireflyconfig')->has(self::PUBLIC_KEY)) {
try {
- $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
- $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
- } catch (ContainerExceptionInterface | NotFoundExceptionInterface | FireflyException $e) {
+ $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
+ $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
+ } catch (ContainerExceptionInterface|NotFoundExceptionInterface|FireflyException $e) {
Log::error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage()));
Log::error($e->getTraceAsString());
}
@@ -122,12 +122,12 @@ class OAuthKeys
*/
public static function restoreKeysFromDB(): bool
{
- $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
- $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
+ $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;
+ $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;
try {
$privateContent = Crypt::decrypt($privateKey);
$publicContent = Crypt::decrypt($publicKey);
- } catch(DecryptException $e) {
+ } catch (DecryptException $e) {
Log::error('Could not decrypt pub/private keypair.');
Log::error($e->getMessage());
@@ -137,8 +137,8 @@ class OAuthKeys
return false;
}
- $private = storage_path('oauth-private.key');
- $public = storage_path('oauth-public.key');
+ $private = storage_path('oauth-private.key');
+ $public = storage_path('oauth-public.key');
file_put_contents($private, $privateContent);
file_put_contents($public, $publicContent);
return true;
diff --git a/app/Support/Twig/AmountFormat.php b/app/Support/Twig/AmountFormat.php
index b874ba32ac..5cc326111d 100644
--- a/app/Support/Twig/AmountFormat.php
+++ b/app/Support/Twig/AmountFormat.php
@@ -45,18 +45,6 @@ class AmountFormat extends AbstractExtension
];
}
- /**
- * {@inheritdoc}
- */
- public function getFunctions(): array
- {
- return [
- $this->formatAmountByAccount(),
- $this->formatAmountBySymbol(),
- $this->formatAmountByCurrency(),
- ];
- }
-
/**
* @return TwigFilter
*/
@@ -89,6 +77,18 @@ class AmountFormat extends AbstractExtension
);
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getFunctions(): array
+ {
+ return [
+ $this->formatAmountByAccount(),
+ $this->formatAmountBySymbol(),
+ $this->formatAmountByCurrency(),
+ ];
+ }
+
/**
* Will format the amount by the currency related to the given account.
*
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index c6631a9961..13859ee55b 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -53,25 +53,6 @@ class General extends AbstractExtension
];
}
- /**
- * {@inheritdoc}
- */
- public function getFunctions(): array
- {
- return [
- $this->phpdate(),
- $this->activeRouteStrict(),
- $this->activeRoutePartial(),
- $this->activeRoutePartialObjectType(),
- $this->menuOpenRoutePartial(),
- $this->formatDate(),
- $this->getMetaField(),
- $this->hasRole(),
- $this->getRootSearchOperator(),
- $this->carbonize()
- ];
- }
-
/**
* Show account balance. Only used on the front page of Firefly III.
*
@@ -93,24 +74,6 @@ class General extends AbstractExtension
);
}
- /**
- * Show URL host name
- *
- * @return TwigFilter
- */
- protected function phpHostName(): TwigFilter
- {
- return new TwigFilter(
- 'phphost',
- static function (string $string): string {
- $proto = (string)parse_url($string, PHP_URL_SCHEME);
- $host = (string)parse_url($string, PHP_URL_HOST);
-
- return e(sprintf('%s://%s', $proto, $host));
- }
- );
- }
-
/**
* Used to convert 1024 to 1kb etc.
*
@@ -232,7 +195,7 @@ class General extends AbstractExtension
]
);
- return (string)$converter->convertToHtml($text);
+ return (string) $converter->convertToHtml($text);
}, ['is_safe' => ['html']]
);
}
@@ -245,11 +208,48 @@ class General extends AbstractExtension
return new TwigFilter(
'floatval',
static function ($value): float {
- return (float)$value;
+ return (float) $value;
+ }
+ );
+ }
+
+ /**
+ * Show URL host name
+ *
+ * @return TwigFilter
+ */
+ protected function phpHostName(): TwigFilter
+ {
+ return new TwigFilter(
+ 'phphost',
+ static function (string $string): string {
+ $proto = (string) parse_url($string, PHP_URL_SCHEME);
+ $host = (string) parse_url($string, PHP_URL_HOST);
+
+ return e(sprintf('%s://%s', $proto, $host));
}
);
}
+ /**
+ * {@inheritdoc}
+ */
+ public function getFunctions(): array
+ {
+ return [
+ $this->phpdate(),
+ $this->activeRouteStrict(),
+ $this->activeRoutePartial(),
+ $this->activeRoutePartialObjectType(),
+ $this->menuOpenRoutePartial(),
+ $this->formatDate(),
+ $this->getMetaField(),
+ $this->hasRole(),
+ $this->getRootSearchOperator(),
+ $this->carbonize(),
+ ];
+ }
+
/**
* Basic example thing for some views.
*
@@ -396,19 +396,6 @@ class General extends AbstractExtension
);
}
- /**
- * @return TwigFunction
- */
- protected function carbonize(): TwigFunction
- {
- return new TwigFunction(
- 'carbonize',
- static function (string $date): Carbon {
- return new Carbon($date);
- }
- );
- }
-
/**
* Will return true if the user is of role X.
*
@@ -438,4 +425,17 @@ class General extends AbstractExtension
}
);
}
+
+ /**
+ * @return TwigFunction
+ */
+ protected function carbonize(): TwigFunction
+ {
+ return new TwigFunction(
+ 'carbonize',
+ static function (string $date): Carbon {
+ return new Carbon($date);
+ }
+ );
+ }
}
diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.php
index f1543f01c9..564547b325 100644
--- a/app/Support/Twig/Rule.php
+++ b/app/Support/Twig/Rule.php
@@ -52,8 +52,8 @@ class Rule extends AbstractExtension
'allJournalTriggers',
static function () {
return [
- 'store-journal' => (string)trans('firefly.rule_trigger_store_journal'),
- 'update-journal' => (string)trans('firefly.rule_trigger_update_journal'),
+ 'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),
+ 'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),
];
}
);
@@ -71,7 +71,7 @@ class Rule extends AbstractExtension
$possibleTriggers = [];
foreach ($ruleTriggers as $key) {
if ('user_action' !== $key) {
- $possibleTriggers[$key] = (string)trans('firefly.rule_trigger_' . $key . '_choice');
+ $possibleTriggers[$key] = (string) trans('firefly.rule_trigger_' . $key . '_choice');
}
}
unset($ruleTriggers);
@@ -94,7 +94,7 @@ class Rule extends AbstractExtension
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
$possibleActions = [];
foreach ($ruleActions as $key) {
- $possibleActions[$key] = (string)trans('firefly.rule_action_' . $key . '_choice');
+ $possibleActions[$key] = (string) trans('firefly.rule_action_' . $key . '_choice');
}
unset($ruleActions);
asort($possibleActions);
diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php
index 96dcd50083..752fd27c79 100644
--- a/app/Support/Twig/Translation.php
+++ b/app/Support/Twig/Translation.php
@@ -40,7 +40,7 @@ class Translation extends AbstractExtension
new TwigFilter(
'_',
static function ($name) {
- return (string)trans(sprintf('firefly.%s', $name));
+ return (string) trans(sprintf('firefly.%s', $name));
},
['is_safe' => ['html']]
),
@@ -65,7 +65,7 @@ class Translation extends AbstractExtension
return new TwigFunction(
'journalLinkTranslation',
static function (string $direction, string $original) {
- $key = sprintf('firefly.%s_%s', $original, $direction);
+ $key = sprintf('firefly.%s_%s', $original, $direction);
$translation = trans($key);
if ($key === $translation) {
return $original;
diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php
index 608515f777..62350cbd44 100644
--- a/app/TransactionRules/Actions/AppendNotes.php
+++ b/app/TransactionRules/Actions/AppendNotes.php
@@ -52,12 +52,12 @@ class AppendNotes implements ActionInterface
{
$dbNote = Note
::
- where('noteable_id', (int)$journal['transaction_journal_id'])
+ where('noteable_id', (int) $journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
->first(['notes.*']);
if (null === $dbNote) {
$dbNote = new Note;
- $dbNote->noteable_id = (int)$journal['transaction_journal_id'];
+ $dbNote->noteable_id = (int) $journal['transaction_journal_id'];
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.php
index c813ef58eb..5de381a3ab 100644
--- a/app/TransactionRules/Actions/LinkToBill.php
+++ b/app/TransactionRules/Actions/LinkToBill.php
@@ -58,7 +58,7 @@ class LinkToBill implements ActionInterface
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->setUser($user);
- $billName = (string)$this->action->action_value;
+ $billName = (string) $this->action->action_value;
$bill = $repository->findByName($billName);
if (null !== $bill && $journal['transaction_type_type'] === TransactionType::WITHDRAWAL) {
diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php
index 569b332dce..4a9f97a426 100644
--- a/app/TransactionRules/Actions/PrependNotes.php
+++ b/app/TransactionRules/Actions/PrependNotes.php
@@ -52,12 +52,12 @@ class PrependNotes implements ActionInterface
{
$dbNote = Note
::
- where('noteable_id', (int)$journal['transaction_journal_id'])
+ where('noteable_id', (int) $journal['transaction_journal_id'])
->where('noteable_type', TransactionJournal::class)
->first(['notes.*']);
if (null === $dbNote) {
$dbNote = new Note;
- $dbNote->noteable_id = (int)$journal['transaction_journal_id'];
+ $dbNote->noteable_id = (int) $journal['transaction_journal_id'];
$dbNote->noteable_type = TransactionJournal::class;
$dbNote->text = '';
}
diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php
index 7cb0e77c1f..4f70ed6e36 100644
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@ -58,7 +58,7 @@ class SetDestinationAccount implements ActionInterface
$user = User::find($journal['user_id']);
$type = $journal['transaction_type_type'];
/** @var TransactionJournal|null $object */
- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);
+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);
$this->repository = app(AccountRepositoryInterface::class);
if (null === $object) {
@@ -95,7 +95,7 @@ class SetDestinationAccount implements ActionInterface
return false;
}
- if (null !== $newAccount && (int)$newAccount->id === (int)$source->account_id) {
+ if (null !== $newAccount && (int) $newAccount->id === (int) $source->account_id) {
Log::error(
sprintf(
'New destination account ID #%d and current source account ID #%d are the same. Do nothing.', $newAccount->id,
diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.php
index 6e4dcc0392..614c771b0f 100644
--- a/app/TransactionRules/Actions/UpdatePiggybank.php
+++ b/app/TransactionRules/Actions/UpdatePiggybank.php
@@ -61,7 +61,7 @@ class UpdatePiggybank implements ActionInterface
// refresh the transaction type.
$user = User::find($journal['user_id']);
$journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);
- $type = TransactionType::find((int)$journalObj->transaction_type_id);
+ $type = TransactionType::find((int) $journalObj->transaction_type_id);
$journal['transaction_type_type'] = $type->type;
if (TransactionType::TRANSFER !== $journal['transaction_type_type']) {
@@ -86,13 +86,13 @@ class UpdatePiggybank implements ActionInterface
/** @var Transaction $destination */
$destination = Transaction::where('transaction_journal_id', $journal['transaction_journal_id'])->where('amount', '>', 0)->first();
- if ((int)$source->account_id === (int)$piggyBank->account_id) {
+ if ((int) $source->account_id === (int) $piggyBank->account_id) {
Log::debug('Piggy bank account is linked to source, so remove amount.');
$this->removeAmount($journal, $piggyBank, $destination->amount);
return true;
}
- if ((int)$destination->account_id === (int)$piggyBank->account_id) {
+ if ((int) $destination->account_id === (int) $piggyBank->account_id) {
Log::debug('Piggy bank account is linked to source, so add amount.');
$this->addAmount($journal, $piggyBank, $destination->amount);
diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php
index 74957670ed..bf6dfb0d75 100644
--- a/app/TransactionRules/Engine/SearchRuleEngine.php
+++ b/app/TransactionRules/Engine/SearchRuleEngine.php
@@ -86,84 +86,6 @@ class SearchRuleEngine implements RuleEngineInterface
return $collection->unique();
}
- /**
- * @inheritDoc
- * @throws FireflyException
- */
- public function fire(): void
- {
- $this->resultCount = [];
- Log::debug('SearchRuleEngine::fire()!');
-
- // if rules and no rule groups, file each rule separately.
- if (0 !== $this->rules->count()) {
- Log::debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));
- foreach ($this->rules as $rule) {
- $this->fireRule($rule);
- }
- Log::debug('SearchRuleEngine:: done processing all rules!');
-
- return;
- }
- if (0 !== $this->groups->count()) {
- Log::debug(sprintf('SearchRuleEngine:: found %d rule group(s) to fire.', $this->groups->count()));
- // fire each group:
- /** @var RuleGroup $group */
- foreach ($this->groups as $group) {
- $this->fireGroup($group);
- }
- }
- Log::debug('SearchRuleEngine:: done processing all rules!');
- }
-
- /**
- * Return the number of changed transactions from the previous "fire" action.
- *
- * @return int
- */
- public function getResults(): int
- {
- return count($this->resultCount);
- }
-
- /**
- * @inheritDoc
- */
- public function setRuleGroups(Collection $ruleGroups): void
- {
- Log::debug(__METHOD__);
- foreach ($ruleGroups as $group) {
- if ($group instanceof RuleGroup) {
- Log::debug(sprintf('Adding a rule group to the SearchRuleEngine: #%d ("%s")', $group->id, $group->title));
- $this->groups->push($group);
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function setRules(Collection $rules): void
- {
-
- Log::debug(__METHOD__);
- foreach ($rules as $rule) {
- if ($rule instanceof Rule) {
- Log::debug(sprintf('Adding a rule to the SearchRuleEngine: #%d ("%s")', $rule->id, $rule->title));
- $this->rules->push($rule);
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function setUser(User $user): void
- {
- $this->user = $user;
- $this->operators = [];
- }
-
/**
* Finds the transactions a strict rule will execute on.
*
@@ -266,7 +188,7 @@ class SearchRuleEngine implements RuleEngineInterface
$journalId = 0;
foreach ($array as $triggerName => $values) {
if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {
- $journalId = (int)trim(($values[0] ?? '"0"'), '"'); // follows format "123".
+ $journalId = (int) trim(($values[0] ?? '"0"'), '"'); // follows format "123".
Log::debug(sprintf('Found journal ID #%d', $journalId));
}
}
@@ -365,6 +287,36 @@ class SearchRuleEngine implements RuleEngineInterface
return $unique;
}
+ /**
+ * @inheritDoc
+ * @throws FireflyException
+ */
+ public function fire(): void
+ {
+ $this->resultCount = [];
+ Log::debug('SearchRuleEngine::fire()!');
+
+ // if rules and no rule groups, file each rule separately.
+ if (0 !== $this->rules->count()) {
+ Log::debug(sprintf('SearchRuleEngine:: found %d rule(s) to fire.', $this->rules->count()));
+ foreach ($this->rules as $rule) {
+ $this->fireRule($rule);
+ }
+ Log::debug('SearchRuleEngine:: done processing all rules!');
+
+ return;
+ }
+ if (0 !== $this->groups->count()) {
+ Log::debug(sprintf('SearchRuleEngine:: found %d rule group(s) to fire.', $this->groups->count()));
+ // fire each group:
+ /** @var RuleGroup $group */
+ foreach ($this->groups as $group) {
+ $this->fireGroup($group);
+ }
+ }
+ Log::debug('SearchRuleEngine:: done processing all rules!');
+ }
+
/**
* Returns true if the rule has been triggered.
*
@@ -460,7 +412,7 @@ class SearchRuleEngine implements RuleEngineInterface
$actions = $rule->ruleActions()->get();
/** @var RuleAction $ruleAction */
foreach ($actions as $ruleAction) {
- if(false === $ruleAction->active) {
+ if (false === $ruleAction->active) {
continue;
}
$break = $this->processRuleAction($ruleAction, $transaction);
@@ -553,4 +505,52 @@ class SearchRuleEngine implements RuleEngineInterface
return $all;
}
+
+ /**
+ * Return the number of changed transactions from the previous "fire" action.
+ *
+ * @return int
+ */
+ public function getResults(): int
+ {
+ return count($this->resultCount);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setRuleGroups(Collection $ruleGroups): void
+ {
+ Log::debug(__METHOD__);
+ foreach ($ruleGroups as $group) {
+ if ($group instanceof RuleGroup) {
+ Log::debug(sprintf('Adding a rule group to the SearchRuleEngine: #%d ("%s")', $group->id, $group->title));
+ $this->groups->push($group);
+ }
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setRules(Collection $rules): void
+ {
+
+ Log::debug(__METHOD__);
+ foreach ($rules as $rule) {
+ if ($rule instanceof Rule) {
+ Log::debug(sprintf('Adding a rule to the SearchRuleEngine: #%d ("%s")', $rule->id, $rule->title));
+ $this->rules->push($rule);
+ }
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setUser(User $user): void
+ {
+ $this->user = $user;
+ $this->operators = [];
+ }
}
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 2d99589767..d3cdbeb094 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -62,8 +62,8 @@ class AccountTransformer extends AbstractTransformer
// get account type:
$fullType = $account->accountType->type;
- $accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
- $liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
+ $accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
+ $liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');
@@ -77,7 +77,7 @@ class AccountTransformer extends AbstractTransformer
[$openingBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType);
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
- $openingBalance = number_format((float)$openingBalance, $decimalPlaces, '.', '');
+ $openingBalance = number_format((float) $openingBalance, $decimalPlaces, '.', '');
$includeNetWorth = '0' !== $this->repository->getMetaValue($account, 'include_net_worth');
$longitude = null;
$latitude = null;
@@ -86,17 +86,17 @@ class AccountTransformer extends AbstractTransformer
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
- $zoomLevel = (int)$location->zoom_level;
+ $zoomLevel = (int) $location->zoom_level;
}
// no order for some accounts:
- $order = (int)$account->order;
+ $order = (int) $account->order;
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'])) {
$order = null;
}
return [
- 'id' => (string)$account->id,
+ 'id' => (string) $account->id,
'created_at' => $account->created_at->toAtomString(),
'updated_at' => $account->updated_at->toAtomString(),
'active' => $account->active,
@@ -108,7 +108,7 @@ class AccountTransformer extends AbstractTransformer
'currency_code' => $currencyCode,
'currency_symbol' => $currencySymbol,
'currency_decimal_places' => $decimalPlaces,
- 'current_balance' => number_format((float)app('steam')->balance($account, $date), $decimalPlaces, '.', ''),
+ 'current_balance' => number_format((float) app('steam')->balance($account, $date), $decimalPlaces, '.', ''),
'current_balance_date' => $date->toAtomString(),
'notes' => $this->repository->getNoteText($account),
'monthly_payment_date' => $monthlyPaymentDate,
@@ -116,7 +116,7 @@ class AccountTransformer extends AbstractTransformer
'account_number' => $this->repository->getMetaValue($account, 'account_number'),
'iban' => '' === $account->iban ? null : $account->iban,
'bic' => $this->repository->getMetaValue($account, 'BIC'),
- 'virtual_balance' => number_format((float)$account->virtual_balance, $decimalPlaces, '.', ''),
+ 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''),
'opening_balance' => $openingBalance,
'opening_balance_date' => $openingBalanceDate,
'liability_type' => $liabilityType,
@@ -147,7 +147,7 @@ class AccountTransformer extends AbstractTransformer
private function getAccountRole(Account $account, string $accountType): ?string
{
$accountRole = $this->repository->getMetaValue($account, 'account_role');
- if ('asset' !== $accountType || '' === (string)$accountRole) {
+ if ('asset' !== $accountType || '' === (string) $accountRole) {
$accountRole = null;
}
@@ -180,7 +180,7 @@ class AccountTransformer extends AbstractTransformer
if (null === $currency) {
$currency = app('amount')->getDefaultCurrencyByUser($account->user);
}
- $currencyId = (string)$currency->id;
+ $currencyId = (string) $currency->id;
$currencyCode = $currency->code;
$decimalPlaces = $currency->decimal_places;
$currencySymbol = $currency->symbol;
diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php
index 5d858ddd25..430feeb9b1 100644
--- a/app/Transformers/AttachmentTransformer.php
+++ b/app/Transformers/AttachmentTransformer.php
@@ -55,10 +55,10 @@ class AttachmentTransformer extends AbstractTransformer
$this->repository->setUser($attachment->user);
return [
- 'id' => (string)$attachment->id,
+ 'id' => (string) $attachment->id,
'created_at' => $attachment->created_at->toAtomString(),
'updated_at' => $attachment->updated_at->toAtomString(),
- 'attachable_id' => (string)$attachment->attachable_id,
+ 'attachable_id' => (string) $attachment->attachable_id,
'attachable_type' => str_replace('FireflyIII\\Models\\', '', $attachment->attachable_type),
'md5' => $attachment->md5,
'filename' => $attachment->filename,
@@ -67,7 +67,7 @@ class AttachmentTransformer extends AbstractTransformer
'title' => $attachment->title,
'notes' => $this->repository->getNoteText($attachment),
'mime' => $attachment->mime,
- 'size' => (int)$attachment->size,
+ 'size' => (int) $attachment->size,
'links' => [
[
'rel' => 'self',
diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.php
index 69ed09f4fa..b9fd050673 100644
--- a/app/Transformers/AvailableBudgetTransformer.php
+++ b/app/Transformers/AvailableBudgetTransformer.php
@@ -62,14 +62,14 @@ class AvailableBudgetTransformer extends AbstractTransformer
$currency = $availableBudget->transactionCurrency;
$data = [
- 'id' => (string)$availableBudget->id,
+ 'id' => (string) $availableBudget->id,
'created_at' => $availableBudget->created_at->toAtomString(),
'updated_at' => $availableBudget->updated_at->toAtomString(),
- 'currency_id' => (string)$currency->id,
+ 'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => (int)$currency->decimal_places,
- 'amount' => number_format((float)$availableBudget->amount, $currency->decimal_places, '.', ''),
+ 'currency_decimal_places' => (int) $currency->decimal_places,
+ 'amount' => number_format((float) $availableBudget->amount, $currency->decimal_places, '.', ''),
'start' => $availableBudget->start_date->toAtomString(),
'end' => $availableBudget->end_date->endOfDay()->toAtomString(),
'spent_in_budgets' => [],
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index b56417b7ce..f641fba83a 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -71,8 +71,8 @@ class BillTransformer extends AbstractTransformer
/** @var ObjectGroup $objectGroup */
$objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) {
- $objectGroupId = (int)$objectGroup->id;
- $objectGroupOrder = (int)$objectGroup->order;
+ $objectGroupId = (int) $objectGroup->id;
+ $objectGroupOrder = (int) $objectGroup->order;
$objectGroupTitle = $objectGroup->title;
}
@@ -106,25 +106,25 @@ class BillTransformer extends AbstractTransformer
unset($temp, $temp2);
return [
- 'id' => (int)$bill->id,
+ 'id' => (int) $bill->id,
'created_at' => $bill->created_at->toAtomString(),
'updated_at' => $bill->updated_at->toAtomString(),
- 'currency_id' => (string)$bill->transaction_currency_id,
+ 'currency_id' => (string) $bill->transaction_currency_id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => (int)$currency->decimal_places,
+ 'currency_decimal_places' => (int) $currency->decimal_places,
'name' => $bill->name,
- 'amount_min' => number_format((float)$bill->amount_min, $currency->decimal_places, '.', ''),
- 'amount_max' => number_format((float)$bill->amount_max, $currency->decimal_places, '.', ''),
+ 'amount_min' => number_format((float) $bill->amount_min, $currency->decimal_places, '.', ''),
+ 'amount_max' => number_format((float) $bill->amount_max, $currency->decimal_places, '.', ''),
'date' => $bill->date->toAtomString(),
'end_date' => $bill->end_date?->toAtomString(),
'extension_date' => $bill->extension_date?->toAtomString(),
'repeat_freq' => $bill->repeat_freq,
- 'skip' => (int)$bill->skip,
+ 'skip' => (int) $bill->skip,
'active' => $bill->active,
- 'order' => (int)$bill->order,
+ 'order' => (int) $bill->order,
'notes' => $notes,
- 'object_group_id' => $objectGroupId ? (string)$objectGroupId : null,
+ 'object_group_id' => $objectGroupId ? (string) $objectGroupId : null,
'object_group_order' => $objectGroupOrder,
'object_group_title' => $objectGroupTitle,
@@ -202,8 +202,8 @@ class BillTransformer extends AbstractTransformer
$result = [];
foreach ($set as $entry) {
$result[] = [
- 'transaction_group_id' => (int)$entry->transaction_group_id,
- 'transaction_journal_id' => (int)$entry->id,
+ 'transaction_group_id' => (int) $entry->transaction_group_id,
+ 'transaction_journal_id' => (int) $entry->id,
'date' => $entry->date->format('Y-m-d'),
];
}
@@ -267,7 +267,7 @@ class BillTransformer extends AbstractTransformer
$nextExpectedMatch->addDay();
$currentStart = clone $nextExpectedMatch;
$loop++;
- if($loop > 4) {
+ if ($loop > 4) {
break;
}
}
diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php
index 55c2caf746..efea0b5d7f 100644
--- a/app/Transformers/BudgetLimitTransformer.php
+++ b/app/Transformers/BudgetLimitTransformer.php
@@ -74,22 +74,22 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencySymbol = null;
if (null !== $currency) {
$amount = $budgetLimit->amount;
- $currencyId = (int)$currency->id;
+ $currencyId = (int) $currency->id;
$currencyName = $currency->name;
$currencyCode = $currency->code;
$currencySymbol = $currency->symbol;
$currencyDecimalPlaces = $currency->decimal_places;
}
- $amount = number_format((float)$amount, $currencyDecimalPlaces, '.', '');
+ $amount = number_format((float) $amount, $currencyDecimalPlaces, '.', '');
return [
- 'id' => (string)$budgetLimit->id,
+ 'id' => (string) $budgetLimit->id,
'created_at' => $budgetLimit->created_at->toAtomString(),
'updated_at' => $budgetLimit->updated_at->toAtomString(),
'start' => $budgetLimit->start_date->toAtomString(),
'end' => $budgetLimit->end_date->endOfDay()->toAtomString(),
- 'budget_id' => (string)$budgetLimit->budget_id,
- 'currency_id' => (string)$currencyId,
+ 'budget_id' => (string) $budgetLimit->budget_id,
+ 'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
'currency_name' => $currencyName,
'currency_decimal_places' => $currencyDecimalPlaces,
diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php
index 129e95d357..295b30fa01 100644
--- a/app/Transformers/CategoryTransformer.php
+++ b/app/Transformers/CategoryTransformer.php
@@ -70,7 +70,7 @@ class CategoryTransformer extends AbstractTransformer
$notes = $this->repository->getNoteText($category);
return [
- 'id' => (int)$category->id,
+ 'id' => (int) $category->id,
'created_at' => $category->created_at->toAtomString(),
'updated_at' => $category->updated_at->toAtomString(),
'name' => $category->name,
@@ -95,7 +95,7 @@ class CategoryTransformer extends AbstractTransformer
{
$return = [];
foreach ($array as $data) {
- $data['sum'] = number_format((float)$data['sum'], (int)$data['currency_decimal_places'], '.', '');
+ $data['sum'] = number_format((float) $data['sum'], (int) $data['currency_decimal_places'], '.', '');
$return[] = $data;
}
diff --git a/app/Transformers/CurrencyTransformer.php b/app/Transformers/CurrencyTransformer.php
index 0c3e1b7966..ab78269e8e 100644
--- a/app/Transformers/CurrencyTransformer.php
+++ b/app/Transformers/CurrencyTransformer.php
@@ -43,11 +43,11 @@ class CurrencyTransformer extends AbstractTransformer
$isDefault = false;
$defaultCurrency = $this->parameters->get('defaultCurrency');
if (null !== $defaultCurrency) {
- $isDefault = (int)$defaultCurrency->id === (int)$currency->id;
+ $isDefault = (int) $defaultCurrency->id === (int) $currency->id;
}
return [
- 'id' => (int)$currency->id,
+ 'id' => (int) $currency->id,
'created_at' => $currency->created_at->toAtomString(),
'updated_at' => $currency->updated_at->toAtomString(),
'default' => $isDefault,
@@ -55,7 +55,7 @@ class CurrencyTransformer extends AbstractTransformer
'name' => $currency->name,
'code' => $currency->code,
'symbol' => $currency->symbol,
- 'decimal_places' => (int)$currency->decimal_places,
+ 'decimal_places' => (int) $currency->decimal_places,
'links' => [
[
'rel' => 'self',
diff --git a/app/Transformers/LinkTypeTransformer.php b/app/Transformers/LinkTypeTransformer.php
index 13f3b36eb5..b1e1097ed5 100644
--- a/app/Transformers/LinkTypeTransformer.php
+++ b/app/Transformers/LinkTypeTransformer.php
@@ -41,7 +41,7 @@ class LinkTypeTransformer extends AbstractTransformer
public function transform(LinkType $linkType): array
{
return [
- 'id' => (int)$linkType->id,
+ 'id' => (int) $linkType->id,
'created_at' => $linkType->created_at->toAtomString(),
'updated_at' => $linkType->updated_at->toAtomString(),
'name' => $linkType->name,
diff --git a/app/Transformers/ObjectGroupTransformer.php b/app/Transformers/ObjectGroupTransformer.php
index d8c19bc2bd..48cb6d48cf 100644
--- a/app/Transformers/ObjectGroupTransformer.php
+++ b/app/Transformers/ObjectGroupTransformer.php
@@ -56,11 +56,11 @@ class ObjectGroupTransformer extends AbstractTransformer
$this->repository->setUser($objectGroup->user);
return [
- 'id' => (string)$objectGroup->id,
+ 'id' => (string) $objectGroup->id,
'created_at' => $objectGroup->created_at->toAtomString(),
'updated_at' => $objectGroup->updated_at->toAtomString(),
'title' => $objectGroup->title,
- 'order' => (int)$objectGroup->order,
+ 'order' => (int) $objectGroup->order,
'links' => [
[
'rel' => 'self',
diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php
index 7f5af318fe..c31e6e4fd6 100644
--- a/app/Transformers/PiggyBankEventTransformer.php
+++ b/app/Transformers/PiggyBankEventTransformer.php
@@ -72,22 +72,22 @@ class PiggyBankEventTransformer extends AbstractTransformer
// get associated journal and transaction, if any:
$journalId = $event->transaction_journal_id;
$groupId = null;
- if (0 !== (int)$journalId) {
- $groupId = (int)$event->transactionJournal->transaction_group_id;
- $journalId = (int)$journalId;
+ if (0 !== (int) $journalId) {
+ $groupId = (int) $event->transactionJournal->transaction_group_id;
+ $journalId = (int) $journalId;
}
return [
- 'id' => (string)$event->id,
+ 'id' => (string) $event->id,
'created_at' => $event->created_at->toAtomString(),
'updated_at' => $event->updated_at->toAtomString(),
- 'amount' => number_format((float)$event->amount, $currency->decimal_places, '.', ''),
- 'currency_id' => (string)$currency->id,
+ 'amount' => number_format((float) $event->amount, $currency->decimal_places, '.', ''),
+ 'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => (int)$currency->decimal_places,
- 'transaction_journal_id' => $journalId ? (string)$journalId : null,
- 'transaction_group_id' => $groupId ? (string)$groupId : null,
+ 'currency_decimal_places' => (int) $currency->decimal_places,
+ 'transaction_journal_id' => $journalId ? (string) $journalId : null,
+ 'transaction_group_id' => $groupId ? (string) $groupId : null,
'links' => [
[
'rel' => 'self',
diff --git a/app/Transformers/PreferenceTransformer.php b/app/Transformers/PreferenceTransformer.php
index c085fbffd7..402966786f 100644
--- a/app/Transformers/PreferenceTransformer.php
+++ b/app/Transformers/PreferenceTransformer.php
@@ -40,7 +40,7 @@ class PreferenceTransformer extends AbstractTransformer
public function transform(Preference $preference): array
{
return [
- 'id' => (int)$preference->id,
+ 'id' => (int) $preference->id,
'created_at' => $preference->created_at->toAtomString(),
'updated_at' => $preference->updated_at->toAtomString(),
'name' => $preference->name,
diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php
index 0bbbb4d37b..5e171eb140 100644
--- a/app/Transformers/RecurrenceTransformer.php
+++ b/app/Transformers/RecurrenceTransformer.php
@@ -80,14 +80,14 @@ class RecurrenceTransformer extends AbstractTransformer
$this->budgetRepos->setUser($recurrence->user);
Log::debug('Set user.');
- $shortType = (string)config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));
+ $shortType = (string) config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));
$notes = $this->repository->getNoteText($recurrence);
- $reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions;
+ $reps = 0 === (int) $recurrence->repetitions ? null : (int) $recurrence->repetitions;
Log::debug('Get basic data.');
// basic data.
return [
- 'id' => (string)$recurrence->id,
+ 'id' => (string) $recurrence->id,
'created_at' => $recurrence->created_at->toAtomString(),
'updated_at' => $recurrence->updated_at->toAtomString(),
'type' => $shortType,
@@ -126,13 +126,13 @@ class RecurrenceTransformer extends AbstractTransformer
/** @var RecurrenceRepetition $repetition */
foreach ($recurrence->recurrenceRepetitions as $repetition) {
$repetitionArray = [
- 'id' => (string)$repetition->id,
+ 'id' => (string) $repetition->id,
'created_at' => $repetition->created_at->toAtomString(),
'updated_at' => $repetition->updated_at->toAtomString(),
'type' => $repetition->repetition_type,
'moment' => $repetition->repetition_moment,
- 'skip' => (int)$repetition->repetition_skip,
- 'weekend' => (int)$repetition->weekend,
+ 'skip' => (int) $repetition->repetition_skip,
+ 'weekend' => (int) $repetition->weekend,
'description' => $this->repository->repetitionDescription($repetition),
'occurrences' => [],
];
@@ -171,10 +171,10 @@ class RecurrenceTransformer extends AbstractTransformer
$foreignCurrencyDp = null;
$foreignCurrencyId = null;
if (null !== $transaction->foreign_currency_id) {
- $foreignCurrencyId = (int)$transaction->foreign_currency_id;
+ $foreignCurrencyId = (int) $transaction->foreign_currency_id;
$foreignCurrencyCode = $transaction->foreignCurrency->code;
$foreignCurrencySymbol = $transaction->foreignCurrency->symbol;
- $foreignCurrencyDp = (int)$transaction->foreignCurrency->decimal_places;
+ $foreignCurrencyDp = (int) $transaction->foreignCurrency->decimal_places;
}
// source info:
@@ -184,7 +184,7 @@ class RecurrenceTransformer extends AbstractTransformer
$sourceIban = null;
if (null !== $sourceAccount) {
$sourceName = $sourceAccount->name;
- $sourceId = (int)$sourceAccount->id;
+ $sourceId = (int) $sourceAccount->id;
$sourceType = $sourceAccount->accountType->type;
$sourceIban = $sourceAccount->iban;
}
@@ -194,29 +194,29 @@ class RecurrenceTransformer extends AbstractTransformer
$destinationIban = null;
if (null !== $destinationAccount) {
$destinationName = $destinationAccount->name;
- $destinationId = (int)$destinationAccount->id;
+ $destinationId = (int) $destinationAccount->id;
$destinationType = $destinationAccount->accountType->type;
$destinationIban = $destinationAccount->iban;
}
- $amount = number_format((float)$transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
+ $amount = number_format((float) $transaction->amount, $transaction->transactionCurrency->decimal_places, '.', '');
$foreignAmount = null;
if (null !== $transaction->foreign_currency_id && null !== $transaction->foreign_amount) {
- $foreignAmount = number_format((float)$transaction->foreign_amount, $foreignCurrencyDp, '.', '');
+ $foreignAmount = number_format((float) $transaction->foreign_amount, $foreignCurrencyDp, '.', '');
}
$transactionArray = [
- 'currency_id' => (string)$transaction->transaction_currency_id,
+ 'currency_id' => (string) $transaction->transaction_currency_id,
'currency_code' => $transaction->transactionCurrency->code,
'currency_symbol' => $transaction->transactionCurrency->symbol,
- 'currency_decimal_places' => (int)$transaction->transactionCurrency->decimal_places,
- 'foreign_currency_id' => null === $foreignCurrencyId ? null : (string)$foreignCurrencyId,
+ 'currency_decimal_places' => (int) $transaction->transactionCurrency->decimal_places,
+ 'foreign_currency_id' => null === $foreignCurrencyId ? null : (string) $foreignCurrencyId,
'foreign_currency_code' => $foreignCurrencyCode,
'foreign_currency_symbol' => $foreignCurrencySymbol,
'foreign_currency_decimal_places' => $foreignCurrencyDp,
- 'source_id' => (string)$sourceId,
+ 'source_id' => (string) $sourceId,
'source_name' => $sourceName,
'source_iban' => $sourceIban,
'source_type' => $sourceType,
- 'destination_id' => (string)$destinationId,
+ 'destination_id' => (string) $destinationId,
'destination_name' => $destinationName,
'destination_iban' => $destinationIban,
'destination_type' => $destinationType,
@@ -264,9 +264,9 @@ class RecurrenceTransformer extends AbstractTransformer
default:
throw new FireflyException(sprintf('Recurrence transformer cant handle field "%s"', $transactionMeta->name));
case 'bill_id':
- $bill = $this->billRepos->find((int)$transactionMeta->value);
+ $bill = $this->billRepos->find((int) $transactionMeta->value);
if (null !== $bill) {
- $array['bill_id'] = (string)$bill->id;
+ $array['bill_id'] = (string) $bill->id;
$array['bill_name'] = $bill->name;
}
break;
@@ -274,30 +274,30 @@ class RecurrenceTransformer extends AbstractTransformer
$array['tags'] = json_decode($transactionMeta->value);
break;
case 'piggy_bank_id':
- $piggy = $this->piggyRepos->find((int)$transactionMeta->value);
+ $piggy = $this->piggyRepos->find((int) $transactionMeta->value);
if (null !== $piggy) {
- $array['piggy_bank_id'] = (string)$piggy->id;
+ $array['piggy_bank_id'] = (string) $piggy->id;
$array['piggy_bank_name'] = $piggy->name;
}
break;
case 'category_id':
- $category = $this->factory->findOrCreate((int)$transactionMeta->value, null);
+ $category = $this->factory->findOrCreate((int) $transactionMeta->value, null);
if (null !== $category) {
- $array['category_id'] = (string)$category->id;
+ $array['category_id'] = (string) $category->id;
$array['category_name'] = $category->name;
}
break;
case 'category_name':
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
if (null !== $category) {
- $array['category_id'] = (string)$category->id;
+ $array['category_id'] = (string) $category->id;
$array['category_name'] = $category->name;
}
break;
case 'budget_id':
- $budget = $this->budgetRepos->find((int)$transactionMeta->value);
+ $budget = $this->budgetRepos->find((int) $transactionMeta->value);
if (null !== $budget) {
- $array['budget_id'] = (string)$budget->id;
+ $array['budget_id'] = (string) $budget->id;
$array['budget_name'] = $budget->name;
}
break;
diff --git a/app/Transformers/RuleGroupTransformer.php b/app/Transformers/RuleGroupTransformer.php
index 7e608b922c..61748c86f6 100644
--- a/app/Transformers/RuleGroupTransformer.php
+++ b/app/Transformers/RuleGroupTransformer.php
@@ -41,7 +41,7 @@ class RuleGroupTransformer extends AbstractTransformer
public function transform(RuleGroup $ruleGroup): array
{
return [
- 'id' => (int)$ruleGroup->id,
+ 'id' => (int) $ruleGroup->id,
'created_at' => $ruleGroup->created_at->toAtomString(),
'updated_at' => $ruleGroup->updated_at->toAtomString(),
'title' => $ruleGroup->title,
diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.php
index 970884912d..b338bb767b 100644
--- a/app/Transformers/RuleTransformer.php
+++ b/app/Transformers/RuleTransformer.php
@@ -60,21 +60,21 @@ class RuleTransformer extends AbstractTransformer
$this->ruleRepository->setUser($rule->user);
return [
- 'id' => (string)$rule->id,
- 'created_at' => $rule->created_at->toAtomString(),
- 'updated_at' => $rule->updated_at->toAtomString(),
- 'rule_group_id' => (string)$rule->rule_group_id,
- 'rule_group_title' => (string)$rule->ruleGroup->title,
- 'title' => $rule->title,
- 'description' => $rule->description,
- 'order' => (int)$rule->order,
- 'active' => $rule->active,
- 'strict' => $rule->strict,
- 'stop_processing' => $rule->stop_processing,
- 'trigger' => $this->getRuleTrigger($rule),
- 'triggers' => $this->triggers($rule),
- 'actions' => $this->actions($rule),
- 'links' => [
+ 'id' => (string) $rule->id,
+ 'created_at' => $rule->created_at->toAtomString(),
+ 'updated_at' => $rule->updated_at->toAtomString(),
+ 'rule_group_id' => (string) $rule->rule_group_id,
+ 'rule_group_title' => (string) $rule->ruleGroup->title,
+ 'title' => $rule->title,
+ 'description' => $rule->description,
+ 'order' => (int) $rule->order,
+ 'active' => $rule->active,
+ 'strict' => $rule->strict,
+ 'stop_processing' => $rule->stop_processing,
+ 'trigger' => $this->getRuleTrigger($rule),
+ 'triggers' => $this->triggers($rule),
+ 'actions' => $this->actions($rule),
+ 'links' => [
[
'rel' => 'self',
'uri' => '/rules/' . $rule->id,
@@ -121,7 +121,7 @@ class RuleTransformer extends AbstractTransformer
continue;
}
$result[] = [
- 'id' => (string)$ruleTrigger->id,
+ 'id' => (string) $ruleTrigger->id,
'created_at' => $ruleTrigger->created_at->toAtomString(),
'updated_at' => $ruleTrigger->updated_at->toAtomString(),
'type' => $ruleTrigger->trigger_type,
@@ -147,7 +147,7 @@ class RuleTransformer extends AbstractTransformer
/** @var RuleAction $ruleAction */
foreach ($actions as $ruleAction) {
$result[] = [
- 'id' => (string)$ruleAction->id,
+ 'id' => (string) $ruleAction->id,
'created_at' => $ruleAction->created_at->toAtomString(),
'updated_at' => $ruleAction->updated_at->toAtomString(),
'type' => $ruleAction->action_type,
diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php
index 56978c9793..b4c09c6560 100644
--- a/app/Transformers/TagTransformer.php
+++ b/app/Transformers/TagTransformer.php
@@ -52,11 +52,11 @@ class TagTransformer extends AbstractTransformer
if (null !== $location) {
$latitude = $location->latitude;
$longitude = $location->longitude;
- $zoomLevel = (int)$location->zoom_level;
+ $zoomLevel = (int) $location->zoom_level;
}
return [
- 'id' => (int)$tag->id,
+ 'id' => (int) $tag->id,
'created_at' => $tag->created_at->toAtomString(),
'updated_at' => $tag->updated_at->toAtomString(),
'tag' => $tag->tag,
diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php
index e628f653af..eba066edb1 100644
--- a/app/Transformers/TransactionGroupTransformer.php
+++ b/app/Transformers/TransactionGroupTransformer.php
@@ -75,10 +75,10 @@ class TransactionGroupTransformer extends AbstractTransformer
$first = new NullArrayObject(reset($group['transactions']));
return [
- 'id' => (int)$first['transaction_group_id'],
+ 'id' => (int) $first['transaction_group_id'],
'created_at' => $first['created_at']->toAtomString(),
'updated_at' => $first['updated_at']->toAtomString(),
- 'user' => (string)$data['user_id'],
+ 'user' => (string) $data['user_id'],
'group_title' => $data['title'],
'transactions' => $this->transformTransactions($data),
'links' => [
@@ -123,13 +123,13 @@ class TransactionGroupTransformer extends AbstractTransformer
$foreignAmount = app('steam')->positive($row['foreign_amount']);
}
- $metaFieldData = $this->groupRepos->getMetaFields((int)$row['transaction_journal_id'], $this->metaFields);
- $metaDateData = $this->groupRepos->getMetaDateFields((int)$row['transaction_journal_id'], $this->metaDateFields);
+ $metaFieldData = $this->groupRepos->getMetaFields((int) $row['transaction_journal_id'], $this->metaFields);
+ $metaDateData = $this->groupRepos->getMetaDateFields((int) $row['transaction_journal_id'], $this->metaDateFields);
$longitude = null;
$latitude = null;
$zoomLevel = null;
- $location = $this->getLocationById((int)$row['transaction_journal_id']);
+ $location = $this->getLocationById((int) $row['transaction_journal_id']);
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
@@ -137,17 +137,17 @@ class TransactionGroupTransformer extends AbstractTransformer
}
return [
- 'user' => (string)$row['user_id'],
- 'transaction_journal_id' => (string)$row['transaction_journal_id'],
+ 'user' => (string) $row['user_id'],
+ 'transaction_journal_id' => (string) $row['transaction_journal_id'],
'type' => strtolower($type),
'date' => $row['date']->toAtomString(),
'order' => $row['order'],
- 'currency_id' => (string)$row['currency_id'],
+ 'currency_id' => (string) $row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_name' => $row['currency_name'],
'currency_symbol' => $row['currency_symbol'],
- 'currency_decimal_places' => (int)$row['currency_decimal_places'],
+ 'currency_decimal_places' => (int) $row['currency_decimal_places'],
'foreign_currency_id' => $this->stringFromArray($transaction, 'foreign_currency_id', null),
'foreign_currency_code' => $row['foreign_currency_code'],
@@ -159,12 +159,12 @@ class TransactionGroupTransformer extends AbstractTransformer
'description' => $row['description'],
- 'source_id' => (string)$row['source_account_id'],
+ 'source_id' => (string) $row['source_account_id'],
'source_name' => $row['source_account_name'],
'source_iban' => $row['source_account_iban'],
'source_type' => $row['source_account_type'],
- 'destination_id' => (string)$row['destination_account_id'],
+ 'destination_id' => (string) $row['destination_account_id'],
'destination_name' => $row['destination_account_name'],
'destination_iban' => $row['destination_account_iban'],
'destination_type' => $row['destination_account_type'],
@@ -179,8 +179,8 @@ class TransactionGroupTransformer extends AbstractTransformer
'bill_name' => $row['bill_name'],
'reconciled' => $row['reconciled'],
- 'notes' => $this->groupRepos->getNoteText((int)$row['transaction_journal_id']),
- 'tags' => $this->groupRepos->getTags((int)$row['transaction_journal_id']),
+ 'notes' => $this->groupRepos->getNoteText((int) $row['transaction_journal_id']),
+ 'tags' => $this->groupRepos->getTags((int) $row['transaction_journal_id']),
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
@@ -213,7 +213,7 @@ class TransactionGroupTransformer extends AbstractTransformer
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
- 'has_attachments' => $this->hasAttachments((int)$row['transaction_journal_id']),
+ 'has_attachments' => $this->hasAttachments((int) $row['transaction_journal_id']),
];
}
@@ -230,11 +230,11 @@ class TransactionGroupTransformer extends AbstractTransformer
return null;
}
if (array_key_exists($key, $array) && null !== $array[$key]) {
- return (string)$array[$key];
+ return (string) $array[$key];
}
if (null !== $default) {
- return (string)$default;
+ return (string) $default;
}
return null;
@@ -250,16 +250,6 @@ class TransactionGroupTransformer extends AbstractTransformer
return $this->groupRepos->getLocation($journalId);
}
- /**
- * @param int $journalId
- *
- * @return bool
- */
- private function hasAttachments(int $journalId): bool
- {
- return $this->groupRepos->countAttachments($journalId) > 0;
- }
-
/**
* @param array $array
* @param string $key
@@ -269,7 +259,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function integerFromArray(array $array, string $key): ?int
{
if (array_key_exists($key, $array)) {
- return (int)$array[$key];
+ return (int) $array[$key];
}
return null;
@@ -290,6 +280,16 @@ class TransactionGroupTransformer extends AbstractTransformer
return $object[$key]->toAtomString();
}
+ /**
+ * @param int $journalId
+ *
+ * @return bool
+ */
+ private function hasAttachments(int $journalId): bool
+ {
+ return $this->groupRepos->countAttachments($journalId) > 0;
+ }
+
/**
* @param TransactionGroup $group
*
@@ -300,10 +300,10 @@ class TransactionGroupTransformer extends AbstractTransformer
{
try {
$result = [
- 'id' => (int)$group->id,
+ 'id' => (int) $group->id,
'created_at' => $group->created_at->toAtomString(),
'updated_at' => $group->updated_at->toAtomString(),
- 'user' => (int)$group->user_id,
+ 'user' => (int) $group->user_id,
'group_title' => $group->title,
'transactions' => $this->transformJournals($group->transactionJournals),
'links' => [
@@ -363,7 +363,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$bill = $this->getBill($journal->bill);
if (null !== $foreignAmount && null !== $foreignCurrency) {
- $foreignAmount = number_format((float)$foreignAmount, $foreignCurrency['decimal_places'] ?? 0, '.', '');
+ $foreignAmount = number_format((float) $foreignAmount, $foreignCurrency['decimal_places'] ?? 0, '.', '');
}
$longitude = null;
@@ -377,33 +377,33 @@ class TransactionGroupTransformer extends AbstractTransformer
}
return [
- 'user' => (int)$journal->user_id,
- 'transaction_journal_id' => (int)$journal->id,
+ 'user' => (int) $journal->user_id,
+ 'transaction_journal_id' => (int) $journal->id,
'type' => strtolower($type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
- 'currency_id' => (int)$currency->id,
+ 'currency_id' => (int) $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => (int)$currency->decimal_places,
+ 'currency_decimal_places' => (int) $currency->decimal_places,
'foreign_currency_id' => $foreignCurrency['id'],
'foreign_currency_code' => $foreignCurrency['code'],
'foreign_currency_symbol' => $foreignCurrency['symbol'],
'foreign_currency_decimal_places' => $foreignCurrency['decimal_places'],
- 'amount' => number_format((float)$amount, $currency->decimal_places, '.', ''),
+ 'amount' => number_format((float) $amount, $currency->decimal_places, '.', ''),
'foreign_amount' => $foreignAmount,
'description' => $journal->description,
- 'source_id' => (int)$source->account_id,
+ 'source_id' => (int) $source->account_id,
'source_name' => $source->account->name,
'source_iban' => $source->account->iban,
'source_type' => $source->account->accountType->type,
- 'destination_id' => (int)$destination->account_id,
+ 'destination_id' => (int) $destination->account_id,
'destination_name' => $destination->account->name,
'destination_iban' => $destination->account->iban,
'destination_type' => $destination->account->accountType->type,
@@ -461,7 +461,7 @@ class TransactionGroupTransformer extends AbstractTransformer
{
$result = $journal->transactions->first(
static function (Transaction $transaction) {
- return (float)$transaction->amount < 0;
+ return (float) $transaction->amount < 0;
}
);
if (null === $result) {
@@ -481,7 +481,7 @@ class TransactionGroupTransformer extends AbstractTransformer
{
$result = $journal->transactions->first(
static function (Transaction $transaction) {
- return (float)$transaction->amount > 0;
+ return (float) $transaction->amount > 0;
}
);
if (null === $result) {
@@ -565,10 +565,10 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $currency) {
return $array;
}
- $array['id'] = (int)$currency->id;
+ $array['id'] = (int) $currency->id;
$array['code'] = $currency->code;
$array['symbol'] = $currency->symbol;
- $array['decimal_places'] = (int)$currency->decimal_places;
+ $array['decimal_places'] = (int) $currency->decimal_places;
return $array;
}
@@ -587,7 +587,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $budget) {
return $array;
}
- $array['id'] = (int)$budget->id;
+ $array['id'] = (int) $budget->id;
$array['name'] = $budget->name;
return $array;
@@ -607,7 +607,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $category) {
return $array;
}
- $array['id'] = (int)$category->id;
+ $array['id'] = (int) $category->id;
$array['name'] = $category->name;
return $array;
@@ -627,7 +627,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $bill) {
return $array;
}
- $array['id'] = (string)$bill->id;
+ $array['id'] = (string) $bill->id;
$array['name'] = $bill->name;
return $array;
diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.php
index b9f3ede0bf..e8a865e93d 100644
--- a/app/Transformers/TransactionLinkTransformer.php
+++ b/app/Transformers/TransactionLinkTransformer.php
@@ -55,12 +55,12 @@ class TransactionLinkTransformer extends AbstractTransformer
$notes = $this->repository->getLinkNoteText($link);
return [
- 'id' => (string)$link->id,
+ 'id' => (string) $link->id,
'created_at' => $link->created_at->toAtomString(),
'updated_at' => $link->updated_at->toAtomString(),
- 'inward_id' => (string)$link->source_id,
- 'outward_id' => (string)$link->destination_id,
- 'link_type_id' => (string)$link->link_type_id,
+ 'inward_id' => (string) $link->source_id,
+ 'outward_id' => (string) $link->destination_id,
+ 'link_type_id' => (string) $link->link_type_id,
'notes' => '' === $notes ? null : $notes,
'links' => [
[
diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php
index 39277ad186..8b8ca5b5ee 100644
--- a/app/Transformers/UserTransformer.php
+++ b/app/Transformers/UserTransformer.php
@@ -46,11 +46,11 @@ class UserTransformer extends AbstractTransformer
$this->repository = $this->repository ?? app(UserRepositoryInterface::class);
return [
- 'id' => (int)$user->id,
+ 'id' => (int) $user->id,
'created_at' => $user->created_at->toAtomString(),
'updated_at' => $user->updated_at->toAtomString(),
'email' => $user->email,
- 'blocked' => 1 === (int)$user->blocked,
+ 'blocked' => 1 === (int) $user->blocked,
'blocked_code' => '' === $user->blocked_code ? null : $user->blocked_code,
'role' => $this->repository->getRoleByUser($user),
'links' => [
diff --git a/app/Transformers/WebhookAttemptTransformer.php b/app/Transformers/WebhookAttemptTransformer.php
index 082828e8ce..a271a917d3 100644
--- a/app/Transformers/WebhookAttemptTransformer.php
+++ b/app/Transformers/WebhookAttemptTransformer.php
@@ -40,11 +40,11 @@ class WebhookAttemptTransformer extends AbstractTransformer
public function transform(WebhookAttempt $attempt): array
{
return [
- 'id' => (string)$attempt->id,
+ 'id' => (string) $attempt->id,
'created_at' => $attempt->created_at->toAtomString(),
'updated_at' => $attempt->updated_at->toAtomString(),
- 'webhook_message_id' => (string)$attempt->webhook_message_id,
- 'status_code' => (int)$attempt->status_code,
+ 'webhook_message_id' => (string) $attempt->webhook_message_id,
+ 'status_code' => (int) $attempt->status_code,
'logs' => $attempt->logs,
'response' => $attempt->response,
];
diff --git a/app/Transformers/WebhookMessageTransformer.php b/app/Transformers/WebhookMessageTransformer.php
index e4f25d938f..9ed9c76d16 100644
--- a/app/Transformers/WebhookMessageTransformer.php
+++ b/app/Transformers/WebhookMessageTransformer.php
@@ -50,12 +50,12 @@ class WebhookMessageTransformer extends AbstractTransformer
}
return [
- 'id' => (string)$message->id,
+ 'id' => (string) $message->id,
'created_at' => $message->created_at->toAtomString(),
'updated_at' => $message->updated_at->toAtomString(),
'sent' => $message->sent,
'errored' => $message->errored,
- 'webhook_id' => (string)$message->webhook_id,
+ 'webhook_id' => (string) $message->webhook_id,
'uuid' => $message->uuid,
'message' => $json,
];
diff --git a/app/Transformers/WebhookTransformer.php b/app/Transformers/WebhookTransformer.php
index 730fa61a89..bc43d58c6c 100644
--- a/app/Transformers/WebhookTransformer.php
+++ b/app/Transformers/WebhookTransformer.php
@@ -52,7 +52,7 @@ class WebhookTransformer extends AbstractTransformer
public function transform(Webhook $webhook): array
{
return [
- 'id' => (int)$webhook->id,
+ 'id' => (int) $webhook->id,
'created_at' => $webhook->created_at->toAtomString(),
'updated_at' => $webhook->updated_at->toAtomString(),
'active' => $webhook->active,
diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.php
index 2987e85a5c..9e71bde252 100644
--- a/app/Validation/Account/DepositValidation.php
+++ b/app/Validation/Account/DepositValidation.php
@@ -40,7 +40,7 @@ trait DepositValidation
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
- * @param array $validTypes
+ * @param array $validTypes
* @param array $data
*
* @return Account|null
@@ -65,7 +65,7 @@ trait DepositValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
- $this->destError = (string)trans('validation.deposit_dest_need_data');
+ $this->destError = (string) trans('validation.deposit_dest_need_data');
Log::error('Both values are NULL, cant create deposit destination.');
$result = false;
}
@@ -80,7 +80,7 @@ trait DepositValidation
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
Log::debug('findExistingAccount() returned NULL, so the result is false.');
- $this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->destError = (string) trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
$result = false;
}
if (null !== $search) {
@@ -114,7 +114,7 @@ trait DepositValidation
// if both values are NULL return false,
// because the source of a deposit can't be created.
// (this never happens).
- $this->sourceError = (string)trans('validation.deposit_source_need_data');
+ $this->sourceError = (string) trans('validation.deposit_source_need_data');
$result = false;
}
diff --git a/app/Validation/Account/LiabilityValidation.php b/app/Validation/Account/LiabilityValidation.php
index 019792f58e..683eabe2d2 100644
--- a/app/Validation/Account/LiabilityValidation.php
+++ b/app/Validation/Account/LiabilityValidation.php
@@ -48,7 +48,7 @@ trait LiabilityValidation
$validTypes = config('firefly.valid_liabilities');
if (null === $accountId) {
- $this->sourceError = (string)trans('validation.lc_destination_need_data');
+ $this->sourceError = (string) trans('validation.lc_destination_need_data');
$result = false;
}
@@ -82,7 +82,7 @@ trait LiabilityValidation
protected function validateLCSource(array $array): bool
{
$accountName = array_key_exists('name', $array) ? $array['name'] : null;
- $result = true;
+ $result = true;
Log::debug('Now in validateLCDestination', $array);
if ('' === $accountName || null === $accountName) {
$result = false;
diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.php
index 9b4b09841a..60b107da9a 100644
--- a/app/Validation/Account/OBValidation.php
+++ b/app/Validation/Account/OBValidation.php
@@ -57,7 +57,7 @@ trait OBValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a deposit can't be created.
- $this->destError = (string)trans('validation.ob_dest_need_data');
+ $this->destError = (string) trans('validation.ob_dest_need_data');
Log::error('Both values are NULL, cant create OB destination.');
$result = false;
}
@@ -72,7 +72,7 @@ trait OBValidation
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
Log::debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);
- $this->destError = (string)trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->destError = (string) trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
$result = false;
}
if (null !== $search) {
@@ -108,7 +108,7 @@ trait OBValidation
// if both values are NULL return false,
// because the source of a deposit can't be created.
// (this never happens).
- $this->sourceError = (string)trans('validation.ob_source_need_data');
+ $this->sourceError = (string) trans('validation.ob_source_need_data');
$result = false;
}
diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php
index 87048e7331..c0e3ddae9a 100644
--- a/app/Validation/Account/ReconciliationValidation.php
+++ b/app/Validation/Account/ReconciliationValidation.php
@@ -33,8 +33,9 @@ use Log;
*/
trait ReconciliationValidation
{
- public ?Account $destination;
- public ?Account $source;
+ public ?Account $destination;
+ public ?Account $source;
+
/**
* @param array $array
*
@@ -42,7 +43,7 @@ trait ReconciliationValidation
*/
protected function validateReconciliationDestination(array $array): bool
{
- $accountId = array_key_exists('id', $array) ? $array['id'] : null;
+ $accountId = array_key_exists('id', $array) ? $array['id'] : null;
Log::debug('Now in validateReconciliationDestination', $array);
if (null === $accountId) {
Log::debug('Return FALSE');
@@ -51,7 +52,7 @@ trait ReconciliationValidation
}
$result = $this->accountRepository->find($accountId);
if (null === $result) {
- $this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
+ $this->destError = (string) trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']);
Log::debug('Return FALSE');
return false;
@@ -76,7 +77,7 @@ trait ReconciliationValidation
return true;
}
- $this->destError = (string)trans('validation.deposit_dest_wrong_type');
+ $this->destError = (string) trans('validation.deposit_dest_wrong_type');
Log::debug('Return FALSE');
return false;
@@ -89,7 +90,7 @@ trait ReconciliationValidation
*/
protected function validateReconciliationSource(array $array): bool
{
- $accountId = array_key_exists('id', $array) ? $array['id'] : null;
+ $accountId = array_key_exists('id', $array) ? $array['id'] : null;
Log::debug('In validateReconciliationSource', $array);
if (null === $accountId) {
Log::debug('Return FALSE');
diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.php
index 3360500f60..06e49a8665 100644
--- a/app/Validation/Account/TransferValidation.php
+++ b/app/Validation/Account/TransferValidation.php
@@ -39,7 +39,7 @@ trait TransferValidation
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
- * @param array $validTypes
+ * @param array $validTypes
* @param array $data
*
* @return Account|null
@@ -61,16 +61,16 @@ trait TransferValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the destination of a transfer can't be created.
- $this->destError = (string)trans('validation.transfer_dest_need_data');
+ $this->destError = (string) trans('validation.transfer_dest_need_data');
Log::error('Both values are NULL, cant create transfer destination.');
return false;
}
// or try to find the account:
- $search = $this->findExistingAccount($validTypes,$array);
+ $search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
- $this->destError = (string)trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->destError = (string) trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
return false;
}
@@ -102,7 +102,7 @@ trait TransferValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the source of a withdrawal can't be created.
- $this->sourceError = (string)trans('validation.transfer_source_need_data');
+ $this->sourceError = (string) trans('validation.transfer_source_need_data');
Log::warning('Not a valid source, need more data.');
return false;
@@ -111,7 +111,7 @@ trait TransferValidation
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
- $this->sourceError = (string)trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
Log::warning('Not a valid source, cant find it.', $validTypes);
return false;
diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.php
index 15919be9e2..5200b16e7c 100644
--- a/app/Validation/Account/WithdrawalValidation.php
+++ b/app/Validation/Account/WithdrawalValidation.php
@@ -40,7 +40,7 @@ trait WithdrawalValidation
abstract protected function canCreateTypes(array $accountTypes): bool;
/**
- * @param array $validTypes
+ * @param array $validTypes
* @param array $data
*
* @return Account|null
@@ -62,7 +62,7 @@ trait WithdrawalValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return TRUE
// because we assume the user doesnt want to submit / change anything.
- $this->sourceError = (string)trans('validation.withdrawal_source_need_data');
+ $this->sourceError = (string) trans('validation.withdrawal_source_need_data');
Log::warning('[a] Not a valid source. Need more data.');
return false;
@@ -71,7 +71,7 @@ trait WithdrawalValidation
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
- $this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
Log::warning('Not a valid source. Cant find it.', $validTypes);
return false;
@@ -97,7 +97,7 @@ trait WithdrawalValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL return false,
// because the destination of a withdrawal can never be created automatically.
- $this->destError = (string)trans('validation.withdrawal_dest_need_data');
+ $this->destError = (string) trans('validation.withdrawal_dest_need_data');
return false;
}
@@ -110,7 +110,7 @@ trait WithdrawalValidation
if (in_array($type, $validTypes, true)) {
return true;
}
- $this->destError = (string)trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->destError = (string) trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);
return false;
}
@@ -136,7 +136,7 @@ trait WithdrawalValidation
if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {
// if both values are NULL we return false,
// because the source of a withdrawal can't be created.
- $this->sourceError = (string)trans('validation.withdrawal_source_need_data');
+ $this->sourceError = (string) trans('validation.withdrawal_source_need_data');
Log::warning('[b] Not a valid source. Need more data.');
return false;
@@ -145,7 +145,7 @@ trait WithdrawalValidation
// otherwise try to find the account:
$search = $this->findExistingAccount($validTypes, $array);
if (null === $search) {
- $this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
+ $this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);
Log::warning('Not a valid source. Cant find it.', $validTypes);
return false;
diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.php
index 1dd6387b3e..16bb89c58c 100644
--- a/app/Validation/AccountValidator.php
+++ b/app/Validation/AccountValidator.php
@@ -198,6 +198,21 @@ class AccountValidator
return false;
}
+ /**
+ * @param string $accountType
+ *
+ * @return bool
+ */
+ protected function canCreateType(string $accountType): bool
+ {
+ $canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];
+ if (in_array($accountType, $canCreate, true)) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* @param array $validTypes
* @param array $data
@@ -244,19 +259,4 @@ class AccountValidator
return null;
}
- /**
- * @param string $accountType
- *
- * @return bool
- */
- protected function canCreateType(string $accountType): bool
- {
- $canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT];
- if (in_array($accountType, $canCreate, true)) {
- return true;
- }
-
- return false;
- }
-
}
diff --git a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
index a4e5146fc4..b67d03384d 100644
--- a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
+++ b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php
@@ -50,26 +50,26 @@ trait ValidatesBulkTransactionQuery
// find both accounts, must be same type.
// already validated: belongs to this user.
$repository = app(AccountRepositoryInterface::class);
- $source = $repository->find((int)$json['where']['account_id']);
- $dest = $repository->find((int)$json['update']['account_id']);
+ $source = $repository->find((int) $json['where']['account_id']);
+ $dest = $repository->find((int) $json['update']['account_id']);
if (null === $source) {
- $validator->errors()->add('query', sprintf((string)trans('validation.invalid_query_data'), 'where', 'account_id'));
+ $validator->errors()->add('query', sprintf((string) trans('validation.invalid_query_data'), 'where', 'account_id'));
return;
}
if (null === $dest) {
- $validator->errors()->add('query', sprintf((string)trans('validation.invalid_query_data'), 'update', 'account_id'));
+ $validator->errors()->add('query', sprintf((string) trans('validation.invalid_query_data'), 'update', 'account_id'));
return;
}
if ($source->accountType->type !== $dest->accountType->type) {
- $validator->errors()->add('query', (string)trans('validation.invalid_query_account_type'));
+ $validator->errors()->add('query', (string) trans('validation.invalid_query_account_type'));
return;
}
// must have same currency:
if ($repository->getAccountCurrency($source)->id !== $repository->getAccountCurrency($dest)->id) {
- $validator->errors()->add('query', (string)trans('validation.invalid_query_currency'));
+ $validator->errors()->add('query', (string) trans('validation.invalid_query_currency'));
}
}
}
diff --git a/app/Validation/CurrencyValidation.php b/app/Validation/CurrencyValidation.php
index 0c48b2a5a2..a1cc7cf921 100644
--- a/app/Validation/CurrencyValidation.php
+++ b/app/Validation/CurrencyValidation.php
@@ -55,7 +55,7 @@ trait CurrencyValidation
) {
$validator->errors()->add(
'transactions.' . $index . '.foreign_amount',
- (string)trans('validation.require_currency_info')
+ (string) trans('validation.require_currency_info')
);
}
// if the currency is present, then the amount must be present as well.
@@ -65,7 +65,7 @@ trait CurrencyValidation
)) {
$validator->errors()->add(
'transactions.' . $index . '.foreign_amount',
- (string)trans('validation.require_currency_amount')
+ (string) trans('validation.require_currency_amount')
);
}
}
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 18e77c7301..76cb848a0d 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -54,47 +54,6 @@ use function is_string;
class FireflyValidator extends Validator
{
- /**
- * @param $attribute
- * @param $value
- * @return bool
- */
- public function validateUniqueCurrencyName($attribute, $value): bool
- {
- return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
- }
-
- /**
- * @param $attribute
- * @param $value
- * @return bool
- */
- public function validateUniqueCurrencyCode($attribute, $value): bool
- {
- return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
- }
-
- /**
- * @param $attribute
- * @param $value
- * @return bool
- */
- public function validateUniqueCurrencySymbol($attribute, $value): bool
- {
- return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
- }
-
- /**
- * @param $attribute
- * @param $value
- * @return bool
- */
- public function validateUniqueCurrency(string $field, string $attribute, string $value): bool
- {
- return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
- }
-
-
/**
* @param mixed $attribute
* @param mixed $value
@@ -648,6 +607,46 @@ class FireflyValidator extends Validator
return true;
}
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencyCode($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('code', (string) $attribute, (string) $value);
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencyName($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('name', (string) $attribute, (string) $value);
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrency(string $field, string $attribute, string $value): bool
+ {
+ return 0 === DB::table('transaction_currencies')->where($field, $value)->whereNull('deleted_at')->count();
+ }
+
+ /**
+ * @param $attribute
+ * @param $value
+ * @return bool
+ */
+ public function validateUniqueCurrencySymbol($attribute, $value): bool
+ {
+ return $this->validateUniqueCurrency('symbol', (string) $attribute, (string) $value);
+ }
+
/**
* @param mixed $value
* @param mixed $parameters
diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.php
index 745adada79..d4802bcc9e 100644
--- a/app/Validation/GroupValidation.php
+++ b/app/Validation/GroupValidation.php
@@ -43,6 +43,36 @@ trait GroupValidation
*/
abstract protected function getTransactionsArray(Validator $validator): array;
+ /**
+ * @param Validator $validator
+ */
+ protected function preventNoAccountInfo(Validator $validator): void
+ {
+ $transactions = $this->getTransactionsArray($validator);
+ $keys = ['source_id', 'destination_id', 'source_name', 'destination_name', 'source_iban', 'destination_iban', 'source_number', 'destination_number'];
+ /** @var array $transaction */
+ foreach ($transactions as $index => $transaction) {
+ $hasAccountInfo = false;
+ $hasJournalId = array_key_exists('transaction_journal_id', $transaction);
+ foreach ($keys as $key) {
+ if (array_key_exists($key, $transaction) && '' !== (string) $transaction[$key]) {
+ $hasAccountInfo = true;
+ }
+ }
+ // set errors:
+ if (false === $hasAccountInfo && !$hasJournalId) {
+ $validator->errors()->add(
+ sprintf('transactions.%d.source_id', $index), (string) trans('validation.generic_no_source')
+ );
+ $validator->errors()->add(
+ sprintf('transactions.%d.destination_id', $index), (string) trans('validation.generic_no_destination')
+ );
+ }
+ }
+
+ // only an issue if there is no transaction_journal_id
+ }
+
/**
* Adds an error to the "description" field when the user has submitted no descriptions and no
* journal description.
@@ -83,36 +113,6 @@ trait GroupValidation
}
}
- /**
- * @param Validator $validator
- */
- protected function preventNoAccountInfo(Validator $validator): void
- {
- $transactions = $this->getTransactionsArray($validator);
- $keys = ['source_id', 'destination_id', 'source_name', 'destination_name', 'source_iban', 'destination_iban', 'source_number', 'destination_number'];
- /** @var array $transaction */
- foreach ($transactions as $index => $transaction) {
- $hasAccountInfo = false;
- $hasJournalId = array_key_exists('transaction_journal_id', $transaction);
- foreach ($keys as $key) {
- if (array_key_exists($key, $transaction) && '' !== (string) $transaction[$key]) {
- $hasAccountInfo = true;
- }
- }
- // set errors:
- if (false === $hasAccountInfo && !$hasJournalId) {
- $validator->errors()->add(
- sprintf('transactions.%d.source_id', $index), (string) trans('validation.generic_no_source')
- );
- $validator->errors()->add(
- sprintf('transactions.%d.destination_id', $index), (string) trans('validation.generic_no_destination')
- );
- }
- }
-
- // only an issue if there is no transaction_journal_id
- }
-
/**
* This method validates if the user has submitted transaction journal ID's for each array they submit, if they've submitted more than 1 transaction
* journal. This check is necessary because Firefly III isn't able to distinguish between journals without the ID.
diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php
index fa5160fbc3..d4400760ee 100644
--- a/app/Validation/RecurrenceValidation.php
+++ b/app/Validation/RecurrenceValidation.php
@@ -91,7 +91,7 @@ trait RecurrenceValidation
continue;
}
// validate source account.
- $sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;
+ $sourceId = array_key_exists('source_id', $transaction) ? (int) $transaction['source_id'] : null;
$sourceName = $transaction['source_name'] ?? null;
$validSource = $accountValidator->validateSource(['id' => $sourceId, 'name' => $sourceName]);
@@ -103,7 +103,7 @@ trait RecurrenceValidation
return;
}
// validate destination account
- $destinationId = array_key_exists('destination_id', $transaction) ? (int)$transaction['destination_id'] : null;
+ $destinationId = array_key_exists('destination_id', $transaction) ? (int) $transaction['destination_id'] : null;
$destinationName = $transaction['destination_name'] ?? null;
$validDestination = $accountValidator->validateDestination(['id' => $destinationId, 'name' => $destinationName,]);
// do something with result:
@@ -127,7 +127,7 @@ trait RecurrenceValidation
$repetitions = $data['repetitions'] ?? [];
// need at least one transaction
if (!is_countable($repetitions) || empty($repetitions)) {
- $validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
+ $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
}
}
@@ -145,7 +145,7 @@ trait RecurrenceValidation
}
// need at least one transaction
if (empty($repetitions)) {
- $validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));
+ $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));
}
}
@@ -162,15 +162,15 @@ trait RecurrenceValidation
$repeatUntil = $data['repeat_until'] ?? null;
if (null !== $repetitions && null !== $repeatUntil) {
// expect a date OR count:
- $validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));
- $validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));
+ $validator->errors()->add('repeat_until', (string) trans('validation.require_repeat_until'));
+ $validator->errors()->add('nr_of_repetitions', (string) trans('validation.require_repeat_until'));
}
}
public function validateRecurringConfig(Validator $validator)
{
$data = $validator->getData();
- $reps = array_key_exists('nr_of_repetitions', $data) ? (int)$data['nr_of_repetitions'] : null;
+ $reps = array_key_exists('nr_of_repetitions', $data) ? (int) $data['nr_of_repetitions'] : null;
$repeatUntil = array_key_exists('repeat_until', $data) ? new Carbon($data['repeat_until']) : null;
if (null === $reps && null === $repeatUntil) {
@@ -193,7 +193,7 @@ trait RecurrenceValidation
$data = $validator->getData();
$repetitions = $data['repetitions'] ?? [];
if (!is_array($repetitions)) {
- $validator->errors()->add(sprintf('repetitions.%d.type', 0), (string)trans('validation.valid_recurrence_rep_type'));
+ $validator->errors()->add(sprintf('repetitions.%d.type', 0), (string) trans('validation.valid_recurrence_rep_type'));
return;
}
@@ -211,23 +211,23 @@ trait RecurrenceValidation
$repetition['moment'] = $repetition['moment'] ?? 'invalid';
switch ($repetition['type'] ?? 'empty') {
default:
- $validator->errors()->add(sprintf('repetitions.%d.type', $index), (string)trans('validation.valid_recurrence_rep_type'));
+ $validator->errors()->add(sprintf('repetitions.%d.type', $index), (string) trans('validation.valid_recurrence_rep_type'));
return;
case 'daily':
- $this->validateDaily($validator, $index, (string)$repetition['moment']);
+ $this->validateDaily($validator, $index, (string) $repetition['moment']);
break;
case 'monthly':
- $this->validateMonthly($validator, $index, (int)$repetition['moment']);
+ $this->validateMonthly($validator, $index, (int) $repetition['moment']);
break;
case 'ndom':
- $this->validateNdom($validator, $index, (string)$repetition['moment']);
+ $this->validateNdom($validator, $index, (string) $repetition['moment']);
break;
case 'weekly':
- $this->validateWeekly($validator, $index, (int)$repetition['moment']);
+ $this->validateWeekly($validator, $index, (int) $repetition['moment']);
break;
case 'yearly':
- $this->validateYearly($validator, $index, (string)$repetition['moment']);
+ $this->validateYearly($validator, $index, (string) $repetition['moment']);
break;
}
}
@@ -243,7 +243,7 @@ trait RecurrenceValidation
protected function validateDaily(Validator $validator, int $index, string $moment): void
{
if ('' !== $moment) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
}
}
@@ -257,7 +257,7 @@ trait RecurrenceValidation
protected function validateMonthly(Validator $validator, int $index, int $dayOfMonth): void
{
if ($dayOfMonth < 1 || $dayOfMonth > 31) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
}
}
@@ -273,19 +273,19 @@ trait RecurrenceValidation
{
$parameters = explode(',', $moment);
if (2 !== count($parameters)) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
return;
}
- $nthDay = (int)($parameters[0] ?? 0.0);
- $dayOfWeek = (int)($parameters[1] ?? 0.0);
+ $nthDay = (int) ($parameters[0] ?? 0.0);
+ $dayOfWeek = (int) ($parameters[1] ?? 0.0);
if ($nthDay < 1 || $nthDay > 5) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
return;
}
if ($dayOfWeek < 1 || $dayOfWeek > 7) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
}
}
@@ -299,7 +299,7 @@ trait RecurrenceValidation
protected function validateWeekly(Validator $validator, int $index, int $dayOfWeek): void
{
if ($dayOfWeek < 1 || $dayOfWeek > 7) {
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
}
}
@@ -316,7 +316,7 @@ trait RecurrenceValidation
Carbon::createFromFormat('Y-m-d', $moment);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage()));
- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));
}
}
}
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 0289c6ab60..25c7c303bd 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -100,10 +100,10 @@ trait TransactionValidation
$accountValidator->setTransactionType($transactionType);
// validate source account.
- $sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;
- $sourceName = array_key_exists('source_name', $transaction) ? (string)$transaction['source_name'] : null;
- $sourceIban = array_key_exists('source_iban', $transaction) ? (string)$transaction['source_iban'] : null;
- $sourceNumber = array_key_exists('source_number', $transaction) ? (string)$transaction['source_number'] : null;
+ $sourceId = array_key_exists('source_id', $transaction) ? (int) $transaction['source_id'] : null;
+ $sourceName = array_key_exists('source_name', $transaction) ? (string) $transaction['source_name'] : null;
+ $sourceIban = array_key_exists('source_iban', $transaction) ? (string) $transaction['source_iban'] : null;
+ $sourceNumber = array_key_exists('source_number', $transaction) ? (string) $transaction['source_number'] : null;
$array = [
'id' => $sourceId,
'name' => $sourceName,
@@ -120,10 +120,10 @@ trait TransactionValidation
return;
}
// validate destination account
- $destinationId = array_key_exists('destination_id', $transaction) ? (int)$transaction['destination_id'] : null;
- $destinationName = array_key_exists('destination_name', $transaction) ? (string)$transaction['destination_name'] : null;
- $destinationIban = array_key_exists('destination_iban', $transaction) ? (string)$transaction['destination_iban'] : null;
- $destinationNumber = array_key_exists('destination_number', $transaction) ? (string)$transaction['destination_number'] : null;
+ $destinationId = array_key_exists('destination_id', $transaction) ? (int) $transaction['destination_id'] : null;
+ $destinationName = array_key_exists('destination_name', $transaction) ? (string) $transaction['destination_name'] : null;
+ $destinationIban = array_key_exists('destination_iban', $transaction) ? (string) $transaction['destination_iban'] : null;
+ $destinationNumber = array_key_exists('destination_number', $transaction) ? (string) $transaction['destination_number'] : null;
$array = [
'id' => $destinationId,
'name' => $destinationName,
@@ -188,7 +188,7 @@ trait TransactionValidation
// validate if the submitted source and / or name are valid
if (array_key_exists('source_id', $transaction) || array_key_exists('source_name', $transaction)) {
Log::debug('Will try to validate source account information.');
- $sourceId = (int)($transaction['source_id'] ?? 0);
+ $sourceId = (int) ($transaction['source_id'] ?? 0);
$sourceName = $transaction['source_name'] ?? null;
$validSource = $accountValidator->validateSource(['id' => $sourceId, 'name' => $sourceName]);
@@ -216,7 +216,7 @@ trait TransactionValidation
$accountValidator->source = $source;
}
}
- $destinationId = (int)($transaction['destination_id'] ?? 0);
+ $destinationId = (int) ($transaction['destination_id'] ?? 0);
$destinationName = $transaction['destination_name'] ?? null;
$array = ['id' => $destinationId, 'name' => $destinationName,];
$validDestination = $accountValidator->validateDestination($array);
@@ -257,7 +257,7 @@ trait TransactionValidation
}
/** @var TransactionJournal $journal */
foreach ($transactionGroup->transactionJournals as $journal) {
- if ((int)$journal->id === (int)$transaction['transaction_journal_id']) {
+ if ((int) $journal->id === (int) $transaction['transaction_journal_id']) {
return $journal->transactions()->where('amount', '<', 0)->first()->account;
}
}
@@ -277,7 +277,7 @@ trait TransactionValidation
// need at least one transaction
if (empty($transactions)) {
- $validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));
+ $validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));
}
}
@@ -292,7 +292,7 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator);
// need at least one transaction
if (empty($transactions)) {
- $validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));
+ $validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));
Log::debug('Added error: at_least_one_transaction.');
return;
@@ -308,7 +308,7 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator);
foreach ($transactions as $key => $value) {
if (!is_int($key)) {
- $validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));
+ $validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));
Log::debug('Added error: at_least_one_transaction.');
return;
@@ -332,13 +332,13 @@ trait TransactionValidation
}
$unique = array_unique($types);
if (count($unique) > 1) {
- $validator->errors()->add('transactions.0.type', (string)trans('validation.transaction_types_equal'));
+ $validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));
return;
}
$first = $unique[0] ?? 'invalid';
if ('invalid' === $first) {
- $validator->errors()->add('transactions.0.type', (string)trans('validation.invalid_transaction_type'));
+ $validator->errors()->add('transactions.0.type', (string) trans('validation.invalid_transaction_type'));
}
}
@@ -353,14 +353,14 @@ trait TransactionValidation
$transactions = $this->getTransactionsArray($validator);
$types = [];
foreach ($transactions as $transaction) {
- $originalType = $this->getOriginalType((int)($transaction['transaction_journal_id'] ?? 0));
+ $originalType = $this->getOriginalType((int) ($transaction['transaction_journal_id'] ?? 0));
// if type is not set, fall back to the type of the journal, if one is given.
$types[] = $transaction['type'] ?? $originalType;
}
$unique = array_unique($types);
if (count($unique) > 1) {
Log::warning('Add error for mismatch transaction types.');
- $validator->errors()->add('transactions.0.type', (string)trans('validation.transaction_types_equal'));
+ $validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));
return;
}
@@ -411,18 +411,18 @@ trait TransactionValidation
default:
case 'withdrawal':
if (count($sources) > 1) {
- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));
}
break;
case 'deposit':
if (count($dests) > 1) {
- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));
}
break;
case'transfer':
if (count($sources) > 1 || count($dests) > 1) {
- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));
- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));
}
break;
}
@@ -453,14 +453,14 @@ trait TransactionValidation
$result = $this->compareAccountData($type, $comparison);
if (false === $result) {
if ('withdrawal' === $type) {
- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));
}
if ('deposit' === $type) {
- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));
}
if ('transfer' === $type) {
- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));
- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));
+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));
}
Log::warning('Add error about equal accounts.');
@@ -483,7 +483,7 @@ trait TransactionValidation
/** @var array $transaction */
foreach ($transactions as $transaction) {
// source or destination may be omitted. If this is the case, use the original source / destination name + ID.
- $originalData = $this->getOriginalData((int)($transaction['transaction_journal_id'] ?? 0));
+ $originalData = $this->getOriginalData((int) ($transaction['transaction_journal_id'] ?? 0));
// get field.
$comparison[$field][] = $transaction[$field] ?? $originalData[$field];