mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 11:08:28 +00:00
Some generic code refactoring.
This commit is contained in:
@@ -55,7 +55,7 @@ class BudgetList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty budget if applicable.
|
||||
if (\in_array(0, $list, true)) {
|
||||
if (in_array(0, $list, true)) {
|
||||
$collection->push(new Budget);
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ class CategoryList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty category if applicable.
|
||||
if (\in_array(0, $list, true)) {
|
||||
if (in_array(0, $list, true)) {
|
||||
$collection->push(new Category);
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ class ConfigurationName implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$accepted = ['is_demo_site', 'permission_update_check', 'single_user_mode'];
|
||||
if (\in_array($value, $accepted, true)) {
|
||||
if (in_array($value, $accepted, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
|
@@ -24,7 +24,7 @@ namespace FireflyIII\Support\Binder;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use Illuminate\Routing\Route;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
@@ -93,7 +93,7 @@ class ImportProvider implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$providers = array_keys(self::getProviders());
|
||||
if (\in_array($value, $providers, true)) {
|
||||
if (in_array($value, $providers, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
|
@@ -57,10 +57,10 @@ class TagList implements BinderInterface
|
||||
|
||||
$collection = $allTags->filter(
|
||||
function (Tag $tag) use ($list) {
|
||||
if (\in_array(strtolower($tag->tag), $list, true)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -119,11 +119,11 @@ class ExpandedForm
|
||||
$currencyId = (int)$repository->getMetaValue($account, 'currency_id');
|
||||
$currency = $currencyRepos->findNull($currencyId);
|
||||
$role = $repository->getMetaValue($account, 'accountRole');
|
||||
if ('' === $role && !\in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
if ('' === $role && !in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if (\in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class ExpandedForm
|
||||
$role = 'no_account_type'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if (\in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_' . $account->accountType->type; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -220,7 +220,7 @@ trait GetConfigurationData
|
||||
}, $forbidden
|
||||
);
|
||||
foreach ($list as $entry) {
|
||||
if (\in_array($entry, $trimmed, true)) {
|
||||
if (in_array($entry, $trimmed, true)) {
|
||||
Log::error('Method "%s" is FORBIDDEN, so the console command cannot be executed.');
|
||||
|
||||
return true;
|
||||
|
@@ -474,6 +474,12 @@ trait PeriodOverview
|
||||
$sumCollector = app(GroupSumCollectorInterface::class);
|
||||
$sumCollector->setTypes($types)->setRange($currentDate['start'], $currentDate['end']);
|
||||
$amounts = $sumCollector->getSum();
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setTypes($types)->setRange($currentDate['start'], $currentDate['end']);
|
||||
$amounts = $collector->getSum();
|
||||
|
||||
$spent = [];
|
||||
$earned = [];
|
||||
$transferred = [];
|
||||
|
@@ -60,7 +60,7 @@ trait RenderPartialViews
|
||||
$set = new Collection;
|
||||
$names = $revenue->pluck('name')->toArray();
|
||||
foreach ($expense as $exp) {
|
||||
if (\in_array($exp->name, $names, true)) {
|
||||
if (in_array($exp->name, $names, true)) {
|
||||
$set->push($exp);
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ trait UserNavigation
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$account = $transaction->account;
|
||||
if (\in_array($account->accountType->type, $valid, true)) {
|
||||
if (in_array($account->accountType->type, $valid, true)) {
|
||||
return redirect(route('accounts.show', [$account->id]));
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
$specifics = $config['specifics'] ?? [];
|
||||
$names = array_keys($specifics);
|
||||
foreach ($names as $name) {
|
||||
if (!\in_array($name, $validSpecifics, true)) {
|
||||
if (!in_array($name, $validSpecifics, true)) {
|
||||
continue;
|
||||
}
|
||||
$class = config(sprintf('csv.import_specifics.%s', $name));
|
||||
@@ -331,7 +331,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
{
|
||||
/** @var array $validColumns */
|
||||
$validColumns = array_keys(config('csv.import_roles'));
|
||||
if (!\in_array($name, $validColumns, true)) {
|
||||
if (!in_array($name, $validColumns, true)) {
|
||||
$name = '_ignore';
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
if ('_ignore' !== $role) {
|
||||
++$assigned;
|
||||
}
|
||||
if (\in_array($role, ['amount', 'amount_credit', 'amount_debit', 'amount_negated'])) {
|
||||
if (in_array($role, ['amount', 'amount_credit', 'amount_debit', 'amount_negated'])) {
|
||||
$hasAmount = true;
|
||||
}
|
||||
if ('foreign-currency-code' === $role) {
|
||||
@@ -372,7 +372,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
$specifics = $config['specifics'] ?? [];
|
||||
$names = array_keys($specifics);
|
||||
foreach ($names as $name) {
|
||||
if (!\in_array($name, $validSpecifics, true)) {
|
||||
if (!in_array($name, $validSpecifics, true)) {
|
||||
continue;
|
||||
}
|
||||
/** @var SpecificInterface $specific */
|
||||
|
@@ -211,7 +211,7 @@ class ImportTransaction
|
||||
$meta = ['sepa_ct_id', 'sepa_ct_op', 'sepa_db', 'sepa_cc', 'sepa_country', 'sepa_batch_id', 'sepa_ep', 'sepa_ci', 'internal_reference', 'date_interest',
|
||||
'date_invoice', 'date_book', 'date_payment', 'date_process', 'date_due', 'original_source'];
|
||||
Log::debug(sprintf('Now going to check role "%s".', $role));
|
||||
if (\in_array($role, $meta, true)) {
|
||||
if (in_array($role, $meta, true)) {
|
||||
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value "%s".', $role, $columnValue->getValue()));
|
||||
$this->meta[$role] = $columnValue->getValue();
|
||||
|
||||
|
@@ -93,7 +93,7 @@ class LineReader
|
||||
$names = array_keys($specifics);
|
||||
$toApply = [];
|
||||
foreach ($names as $name) {
|
||||
if (!\in_array($name, $validSpecifics, true)) {
|
||||
if (!in_array($name, $validSpecifics, true)) {
|
||||
continue;
|
||||
}
|
||||
$class = config(sprintf('csv.import_specifics.%s', $name));
|
||||
|
@@ -233,7 +233,7 @@ class StageImportDataHandler
|
||||
if (null === $account) {
|
||||
throw new FireflyException(sprintf('Cannot find Firefly III asset account with ID #%d. Job must stop now.', $accountId)); // @codeCoverageIgnore
|
||||
}
|
||||
if (!\in_array($account->accountType->type, [AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
|
||||
if (!in_array($account->accountType->type, [AccountType::ASSET, AccountType::LOAN, AccountType::MORTGAGE, AccountType::DEBT], true)) {
|
||||
throw new FireflyException(
|
||||
sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)
|
||||
); // @codeCoverageIgnore
|
||||
|
@@ -24,7 +24,7 @@ namespace FireflyIII\Support;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class Navigation
|
||||
|
||||
$months = ['1M', 'month', 'monthly'];
|
||||
$difference = $date->month - $theDate->month;
|
||||
if (2 === $difference && $date->day > 0 && \in_array($repeatFreq, $months, true)) {
|
||||
if (2 === $difference && $date->day > 0 && in_array($repeatFreq, $months, true)) {
|
||||
$date->subDays($date->day);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ class Navigation
|
||||
|
||||
if (isset($modifierMap[$repeatFreq])) {
|
||||
$currentEnd->$function($modifierMap[$repeatFreq]);
|
||||
if (\in_array($repeatFreq, $subDay, true)) {
|
||||
if (in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
}
|
||||
$currentEnd->endOfDay();
|
||||
@@ -236,7 +236,7 @@ class Navigation
|
||||
}
|
||||
$currentEnd->$function();
|
||||
$currentEnd->endOfDay();
|
||||
if (\in_array($repeatFreq, $subDay, true)) {
|
||||
if (in_array($repeatFreq, $subDay, true)) {
|
||||
$currentEnd->subDay();
|
||||
}
|
||||
|
||||
|
@@ -139,7 +139,7 @@ class Search implements SearchInterface
|
||||
if (2 === count($parts) && '' !== trim((string)$parts[1]) && '' !== trim((string)$parts[0])) {
|
||||
$type = trim((string)$parts[0]);
|
||||
$value = trim((string)$parts[1]);
|
||||
if (\in_array($type, $this->validModifiers, true)) {
|
||||
if (in_array($type, $this->validModifiers, true)) {
|
||||
// filter for valid type
|
||||
$this->modifiers->push(['type' => $type, 'value' => $value]);
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ class General extends Twig_Extension
|
||||
return new Twig_SimpleFunction(
|
||||
'activeRouteStrict',
|
||||
function (): string {
|
||||
$args = \func_get_args();
|
||||
$args = func_get_args();
|
||||
$route = $args[0]; // name of the route.
|
||||
|
||||
if (Route::getCurrentRoute()->getName() === $route) {
|
||||
|
Reference in New Issue
Block a user