Some generic code refactoring.

This commit is contained in:
James Cole
2019-06-21 19:10:02 +02:00
parent fb1af395f9
commit 2d3d7f7720
67 changed files with 920 additions and 603 deletions

View File

@@ -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';
}

View File

@@ -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 */

View File

@@ -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();

View File

@@ -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));

View File

@@ -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