mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
Reformat various code.
This commit is contained in:
@@ -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'])) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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.';
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user