First part of a large code cleanup commit.

This commit is contained in:
James Cole
2019-02-12 21:49:28 +01:00
parent b273af341c
commit e0d87aa11e
70 changed files with 336 additions and 354 deletions

View File

@@ -151,7 +151,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
{
foreach ($line as $column => $value) {
$value = trim($value);
if (\strlen($value) > 0) {
if ('' != $value) {
$this->examples[$column][] = $value;
}
}
@@ -219,7 +219,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
try {
$stmt = (new Statement)->limit(1)->offset(0);
$records = $stmt->process($reader);
$headers = $records->fetchOne(0);
$headers = $records->fetchOne();
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());

View File

@@ -78,7 +78,6 @@ class ChooseAccountHandler implements FinTSConfigurationInterface
* Get the data necessary to show the configuration screen.
*
* @return array
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function getNextData(): array
{

View File

@@ -48,7 +48,6 @@ class NewFinTSJobHandler implements FinTSConfigurationInterface
* @param array $data
*
* @return MessageBag
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function configureJob(array $data): MessageBag
{

View File

@@ -152,7 +152,7 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
$client = new Client();
try {
$res = $client->request('post', $uri, []);
$res = $client->request('post', $uri);
} catch (GuzzleException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());

View File

@@ -88,7 +88,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
// validate each
$ynabId = $this->validYnabAccount($ynabId);
$accountId = $this->validLocalAccount((int)$localId);
if ($accountId !== 0) {
if (0 !== $accountId) {
$final[$ynabId] = $accountId;
}
}

View File

@@ -186,7 +186,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'];
'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)) {
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value "%s".', $role, $columnValue->getValue()));

View File

@@ -65,7 +65,9 @@ class PaymentConverter
/**
* Convert a bunq transaction to a usable transaction for Firefly III.
*
* @param BunqPayment $payment
* @param BunqPayment $payment
*
* @param LocalAccount $source
*
* @return array
* @throws FireflyException

View File

@@ -39,6 +39,7 @@ class StageFinalHandler
/**
* @return array
* @throws \Exception
*/
public function getTransactions(): array
{

View File

@@ -183,7 +183,7 @@ class MappingConverger
$value = trim($value);
$originalRole = $this->roles[$columnIndex] ?? '_ignore';
Log::debug(sprintf('Now at column #%d (%s), value "%s"', $columnIndex, $originalRole, $value));
if ('_ignore' !== $originalRole && \strlen($value) > 0) {
if ('_ignore' !== $originalRole && '' != $value) {
// is a mapped value present?
$mapped = $this->mapping[$columnIndex][$value] ?? 0;

View File

@@ -66,13 +66,13 @@ class StageImportDataHandler
/**
* @throws FireflyException
*/
public function run()
public function run(): void
{
Log::debug('Now in StageImportDataHandler::run()');
$localAccount = $this->accountRepository->findNull((int)$this->importJob->configuration['local_account']);
if (null === $localAccount) {
throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ' , $this->importJob->configuration['local_account']));
throw new FireflyException(sprintf('Cannot find Firefly account with id #%d ', $this->importJob->configuration['local_account']));
}
$finTS = app(FinTS::class, ['config' => $this->importJob->configuration]);
$fintTSAccount = $finTS->getAccount($this->importJob->configuration['fints_account']);
@@ -143,8 +143,8 @@ class StageImportDataHandler
}
$metadataParser = new MetadataParser();
$description = $metadataParser->getDescription($transaction);
$description = $metadataParser->getDescription($transaction);
$storeData = [
'user' => $this->importJob->user_id,
'type' => $type,

View File

@@ -233,8 +233,10 @@ 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)) {
throw new FireflyException(sprintf('Account with ID #%d is not an asset/loan/mortgage/debt account. Job must stop now.', $accountId)); // @codeCoverageIgnore
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
}
return $account;