Code cleanup that (hopefully) matches style CI

This commit is contained in:
James Cole 2020-03-17 15:03:08 +01:00
parent 24129ab69c
commit 91c067ac9f
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
48 changed files with 182 additions and 131 deletions

View File

@ -26,6 +26,7 @@ use Log;
/** /**
* Class Amount. * Class Amount.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -46,7 +47,7 @@ class Amount implements ConverterInterface
} }
Log::debug(sprintf('Start with amount "%s"', $value)); Log::debug(sprintf('Start with amount "%s"', $value));
$original = $value; $original = $value;
$value = $this->stripAmount((string)$value); $value = $this->stripAmount((string) $value);
$decimal = null; $decimal = null;
if ($this->decimalIsDot($value)) { if ($this->decimalIsDot($value)) {
@ -219,7 +220,7 @@ class Amount implements ConverterInterface
$value = substr($value, 2); $value = substr($value, 2);
} }
// have to strip the € because apparantly the Postbank (DE) thinks "1.000,00 €" is a normal way to format a number. // have to strip the € because apparantly the Postbank (DE) thinks "1.000,00 €" is a normal way to format a number.
$value = trim((string)str_replace(['€'], '', $value)); $value = trim((string) str_replace(['€'], '', $value));
$str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value); $str = preg_replace('/[^\-\(\)\.\,0-9 ]/', '', $value);
$len = strlen($str); $len = strlen($str);
if ('(' === $str[0] && ')' === $str[$len - 1]) { if ('(' === $str[0] && ')' === $str[$len - 1]) {

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/** /**
* Class AmountCredit * Class AmountCredit
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/** /**
* Class AmountDebit * Class AmountDebit
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/** /**
* Class AmountNegated * Class AmountNegated
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -29,6 +29,7 @@ use Log;
/** /**
* *
* Class BankDebitCredit * Class BankDebitCredit
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -38,9 +39,10 @@ class BankDebitCredit implements ConverterInterface
/** /**
* Convert a value. * Convert a value.
* *
* @param $value
*
* @return mixed * @return mixed
* *
* @param $value
*/ */
public function convert($value): int public function convert($value): int
{ {

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Converter;
/** /**
* Interface ConverterInterface. * Interface ConverterInterface.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -32,9 +33,10 @@ interface ConverterInterface
/** /**
* Convert a value. * Convert a value.
* *
* @param $value
*
* @return mixed * @return mixed
* *
* @param $value
*/ */
public function convert($value); public function convert($value);
} }

View File

@ -34,6 +34,7 @@ use Log;
/** /**
* Class BunqJobConfiguration * Class BunqJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -107,8 +108,8 @@ class BunqJobConfiguration implements JobConfigurationInterface
/** /**
* Get correct handler. * Get correct handler.
* *
* @return BunqJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
* @return BunqJobConfigurationInterface
*/ */
private function getHandler(): BunqJobConfigurationInterface private function getHandler(): BunqJobConfigurationInterface
{ {

View File

@ -29,6 +29,7 @@ use Illuminate\Support\MessageBag;
/** /**
* Class FakeJobConfiguration * Class FakeJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -78,7 +79,7 @@ class FakeJobConfiguration implements JobConfigurationInterface
$artist = strtolower($data['artist'] ?? ''); $artist = strtolower($data['artist'] ?? '');
$song = strtolower($data['song'] ?? ''); $song = strtolower($data['song'] ?? '');
$album = strtolower($data['album'] ?? ''); $album = strtolower($data['album'] ?? '');
$applyRules = isset($data['apply_rules']) ? 1 === (int)$data['apply_rules'] : null; $applyRules = isset($data['apply_rules']) ? 1 === (int) $data['apply_rules'] : null;
$configuration = $this->importJob->configuration; $configuration = $this->importJob->configuration;
if ('david bowie' === $artist) { if ('david bowie' === $artist) {
// store artist // store artist
@ -118,8 +119,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
{ {
return [ return [
'rulesOptions' => [ 'rulesOptions' => [
1 => (string)trans('firefly.yes'), 1 => (string) trans('firefly.yes'),
0 => (string)trans('firefly.no'), 0 => (string) trans('firefly.no'),
], ],
]; ];
} }

View File

@ -37,6 +37,7 @@ use Illuminate\Support\MessageBag;
/** /**
* Class FileJobConfiguration * Class FileJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -63,8 +64,8 @@ class FileJobConfiguration implements JobConfigurationInterface
* *
* @param array $data * @param array $data
* *
* @return MessageBag
* @throws FireflyException * @throws FireflyException
* @return MessageBag
*/ */
public function configureJob(array $data): MessageBag public function configureJob(array $data): MessageBag
{ {
@ -91,9 +92,9 @@ class FileJobConfiguration implements JobConfigurationInterface
/** /**
* Returns the view of the next step in the job configuration. * Returns the view of the next step in the job configuration.
* *
* @throws FireflyException
* @return string * @return string
* *
*@throws FireflyException
*/ */
public function getNextView(): string public function getNextView(): string
{ {
@ -130,9 +131,9 @@ class FileJobConfiguration implements JobConfigurationInterface
/** /**
* Get the configuration handler for this specific stage. * Get the configuration handler for this specific stage.
* *
* @return FileConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @return FileConfigurationInterface
*/ */
private function getConfigurationObject(): FileConfigurationInterface private function getConfigurationObject(): FileConfigurationInterface
{ {

View File

@ -26,6 +26,7 @@ namespace FireflyIII\Import\JobConfiguration;
/** /**
* *
* Class FinTSConfigurationSteps * Class FinTSConfigurationSteps
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -32,6 +32,7 @@ use Illuminate\Support\MessageBag;
/** /**
* *
* Class FinTSJobConfiguration * Class FinTSJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -56,8 +57,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
* *
* @param array $data * @param array $data
* *
* @return MessageBag
* @throws FireflyException * @throws FireflyException
* @return MessageBag
*/ */
public function configureJob(array $data): MessageBag public function configureJob(array $data): MessageBag
{ {
@ -67,8 +68,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/** /**
* Return the data required for the next step in the job configuration. * Return the data required for the next step in the job configuration.
* *
* @return array
* @throws FireflyException * @throws FireflyException
* @return array
*/ */
public function getNextData(): array public function getNextData(): array
{ {
@ -78,8 +79,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/** /**
* Returns the view of the next step in the job configuration. * Returns the view of the next step in the job configuration.
* *
* @return string
* @throws FireflyException * @throws FireflyException
* @return string
*/ */
public function getNextView(): string public function getNextView(): string
{ {
@ -108,8 +109,8 @@ class FinTSJobConfiguration implements JobConfigurationInterface
/** /**
* Get the configuration handler for this specific stage. * Get the configuration handler for this specific stage.
* *
* @return FinTSConfigurationInterface
* @throws FireflyException * @throws FireflyException
* @return FinTSConfigurationInterface
*/ */
private function getConfigurationObject(): FinTSConfigurationInterface private function getConfigurationObject(): FinTSConfigurationInterface
{ {

View File

@ -27,6 +27,7 @@ use Illuminate\Support\MessageBag;
/** /**
* Interface JobConfigurationInterface. * Interface JobConfigurationInterface.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -37,6 +37,7 @@ use Log;
/** /**
* Class SpectreJobConfiguration * Class SpectreJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -110,9 +111,9 @@ class SpectreJobConfiguration implements JobConfigurationInterface
/** /**
* Get correct handler. * Get correct handler.
* *
* @return SpectreJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @return SpectreJobConfigurationInterface
*/ */
private function getHandler(): SpectreJobConfigurationInterface private function getHandler(): SpectreJobConfigurationInterface
{ {

View File

@ -35,6 +35,7 @@ use Log;
/** /**
* Class YnabJobConfiguration * Class YnabJobConfiguration
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -108,9 +109,9 @@ class YnabJobConfiguration implements JobConfigurationInterface
/** /**
* Get correct handler. * Get correct handler.
* *
* @return YnabJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
* *
* @return YnabJobConfigurationInterface
*/ */
private function getHandler(): YnabJobConfigurationInterface private function getHandler(): YnabJobConfigurationInterface
{ {

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/** /**
* Class AssetAccounts. * Class AssetAccounts.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -54,7 +55,7 @@ class AssetAccountIbans implements MapperInterface
/** @var Account $account */ /** @var Account $account */
foreach ($set as $account) { foreach ($set as $account) {
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
$accountId = (int)$account->id; $accountId = (int) $account->id;
if ('' !== $iban) { if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')'; $name = $account->iban . ' (' . $account->name . ')';
@ -77,7 +78,7 @@ class AssetAccountIbans implements MapperInterface
/** @noinspection AdditionOperationOnArraysInspection */ /** @noinspection AdditionOperationOnArraysInspection */
$list = $topList + $list; $list = $topList + $list;
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/** /**
* Class AssetAccounts. * Class AssetAccounts.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -49,7 +50,7 @@ class AssetAccounts implements MapperInterface
/** @var Account $account */ /** @var Account $account */
foreach ($set as $account) { foreach ($set as $account) {
$accountId = (int)$account->id; $accountId = (int) $account->id;
$name = $account->name; $name = $account->name;
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
if ('' !== $iban) { if ('' !== $iban) {
@ -64,7 +65,7 @@ class AssetAccounts implements MapperInterface
$list[$accountId] = $name; $list[$accountId] = $name;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
/** /**
* Class Bills. * Class Bills.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -46,11 +47,11 @@ class Bills implements MapperInterface
/** @var Bill $bill */ /** @var Bill $bill */
foreach ($result as $bill) { foreach ($result as $bill) {
$billId = (int)$bill->id; $billId = (int) $bill->id;
$list[$billId] = $bill->name; $list[$billId] = $bill->name;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/** /**
* Class Budgets. * Class Budgets.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -46,11 +47,11 @@ class Budgets implements MapperInterface
/** @var Budget $budget */ /** @var Budget $budget */
foreach ($result as $budget) { foreach ($result as $budget) {
$budgetId = (int)$budget->id; $budgetId = (int) $budget->id;
$list[$budgetId] = $budget->name; $list[$budgetId] = $budget->name;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
/** /**
* Class Categories. * Class Categories.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -46,11 +47,11 @@ class Categories implements MapperInterface
/** @var Category $category */ /** @var Category $category */
foreach ($result as $category) { foreach ($result as $category) {
$categoryId = (int)$category->id; $categoryId = (int) $category->id;
$list[$categoryId] = $category->name; $list[$categoryId] = $category->name;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Mapper;
/** /**
* Interface MapperInterface. * Interface MapperInterface.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/** /**
* Class OpposingAccounts. * Class OpposingAccounts.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -56,7 +57,7 @@ class OpposingAccountIbans implements MapperInterface
/** @var Account $account */ /** @var Account $account */
foreach ($set as $account) { foreach ($set as $account) {
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
$accountId = (int)$account->id; $accountId = (int) $account->id;
if ('' !== $iban) { if ('' !== $iban) {
$name = $account->iban . ' (' . $account->name . ')'; $name = $account->iban . ' (' . $account->name . ')';
@ -80,7 +81,7 @@ class OpposingAccountIbans implements MapperInterface
/** @noinspection AdditionOperationOnArraysInspection */ /** @noinspection AdditionOperationOnArraysInspection */
$list = $topList + $list; $list = $topList + $list;
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/** /**
* Class OpposingAccounts. * Class OpposingAccounts.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@ -55,7 +56,7 @@ class OpposingAccounts implements MapperInterface
/** @var Account $account */ /** @var Account $account */
foreach ($set as $account) { foreach ($set as $account) {
$accountId = (int)$account->id; $accountId = (int) $account->id;
$name = $account->name; $name = $account->name;
$iban = $account->iban ?? ''; $iban = $account->iban ?? '';
if ('' !== $iban) { if ('' !== $iban) {
@ -68,7 +69,7 @@ class OpposingAccounts implements MapperInterface
$list[$accountId] = $name; $list[$accountId] = $name;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -27,6 +27,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
/** /**
* Class Tags. * Class Tags.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -46,11 +47,11 @@ class Tags implements MapperInterface
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($result as $tag) { foreach ($result as $tag) {
$tagId = (int)$tag->id; $tagId = (int) $tag->id;
$list[$tagId] = $tag->tag; $list[$tagId] = $tag->tag;
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -26,6 +26,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/** /**
* Class TransactionCurrencies. * Class TransactionCurrencies.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -43,12 +44,12 @@ class TransactionCurrencies implements MapperInterface
$currencies = $repository->get(); $currencies = $repository->get();
$list = []; $list = [];
foreach ($currencies as $currency) { foreach ($currencies as $currency) {
$currencyId = (int)$currency->id; $currencyId = (int) $currency->id;
$list[$currencyId] = $currency->name . ' (' . $currency->code . ')'; $list[$currencyId] = $currency->name . ' (' . $currency->code . ')';
} }
asort($list); asort($list);
$list = [0 => (string)trans('import.map_do_not_map')] + $list; $list = [0 => (string) trans('import.map_do_not_map')] + $list;
return $list; return $list;
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/** /**
* Interface PreProcessorInterface. * Interface PreProcessorInterface.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/** /**
* Class TagsComma. * Class TagsComma.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\MapperPreProcess;
/** /**
* Class TagsSpace. * Class TagsSpace.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -33,6 +33,7 @@ use Log;
/** /**
* This class contains all the routines necessary to connect to Bunq. * This class contains all the routines necessary to connect to Bunq.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -82,7 +83,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (!$this->hasExternalIP()) { if (!$this->hasExternalIP()) {
/** @var IPRetrievalInterface $service */ /** @var IPRetrievalInterface $service */
$service = app(IPRetrievalInterface::class); $service = app(IPRetrievalInterface::class);
$externalIP = (string)$service->getIP(); $externalIP = (string) $service->getIP();
} }
return ['api_key' => $key, 'external_ip' => $externalIP]; return ['api_key' => $key, 'external_ip' => $externalIP];
@ -190,7 +191,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $apiContext) { if (null === $apiContext) {
return false; return false;
} }
if ('' === (string)$apiContext->data) { if ('' === (string) $apiContext->data) {
return false; return false;
} }
@ -208,7 +209,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $apiKey) { if (null === $apiKey) {
return false; return false;
} }
if ('' === (string)$apiKey->data) { if ('' === (string) $apiKey->data) {
return false; return false;
} }
@ -226,7 +227,7 @@ class BunqPrerequisites implements PrerequisitesInterface
if (null === $externalIP) { if (null === $externalIP) {
return false; return false;
} }
if ('' === (string)$externalIP->data) { if ('' === (string) $externalIP->data) {
return false; return false;
} }

View File

@ -25,11 +25,13 @@ namespace FireflyIII\Import\Prerequisites;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
use Log; use Log;
use function request;
/** /**
* This class contains all the routines necessary for the fake import provider. * This class contains all the routines necessary for the fake import provider.
* *
* Class FakePrerequisites * Class FakePrerequisites
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -70,9 +72,9 @@ class FakePrerequisites implements PrerequisitesInterface
if ($this->hasApiKey()) { if ($this->hasApiKey()) {
$apiKey = app('preferences')->getForUser($this->user, 'fake_api_key', null)->data; $apiKey = app('preferences')->getForUser($this->user, 'fake_api_key', null)->data;
} }
$oldKey = (string)\request()->old('api_key'); $oldKey = (string) request()->old('api_key');
if ('' !== $oldKey) { if ('' !== $oldKey) {
$apiKey = \request()->old('api_key'); // @codeCoverageIgnore $apiKey = request()->old('api_key'); // @codeCoverageIgnore
} }
return ['api_key' => $apiKey]; return ['api_key' => $apiKey];
@ -135,7 +137,7 @@ class FakePrerequisites implements PrerequisitesInterface
if (null === $apiKey->data) { if (null === $apiKey->data) {
return false; return false;
} }
if (32 === strlen((string)$apiKey->data)) { if (32 === strlen((string) $apiKey->data)) {
return true; return true;
} }

View File

@ -45,6 +45,7 @@ class FilePrerequisites implements PrerequisitesInterface
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
} }
} }
/** /**
* Returns view name that allows user to fill in prerequisites. * Returns view name that allows user to fill in prerequisites.
* *

View File

@ -27,6 +27,7 @@ use Illuminate\Support\MessageBag;
/** /**
* Interface PrerequisitesInterface * Interface PrerequisitesInterface
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -29,6 +29,7 @@ use Log;
/** /**
* This class contains all the routines necessary to connect to Spectre. * This class contains all the routines necessary to connect to Spectre.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -178,7 +179,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
if (null === $appId) { if (null === $appId) {
return false; return false;
} }
if ('' === (string)$appId->data) { if ('' === (string) $appId->data) {
return false; return false;
} }
@ -196,7 +197,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
if (null === $secret) { if (null === $secret) {
return false; return false;
} }
if ('' === (string)$secret->data) { if ('' === (string) $secret->data) {
return false; return false;
} }

View File

@ -29,6 +29,7 @@ use Log;
/** /**
* Class YnabPrerequisites * Class YnabPrerequisites
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -131,7 +132,7 @@ class YnabPrerequisites implements PrerequisitesInterface
if (null === $clientId) { if (null === $clientId) {
return false; return false;
} }
if ('' === (string)$clientId->data) { if ('' === (string) $clientId->data) {
return false; return false;
} }
@ -149,7 +150,7 @@ class YnabPrerequisites implements PrerequisitesInterface
if (null === $clientSecret) { if (null === $clientSecret) {
return false; return false;
} }
if ('' === (string)$clientSecret->data) { if ('' === (string) $clientSecret->data) {
return false; return false;
} }

View File

@ -32,6 +32,7 @@ use Log;
/** /**
* Class BunqRoutine * Class BunqRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -33,6 +33,7 @@ use Log;
/** /**
* Class FakeRoutine * Class FakeRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -51,9 +52,9 @@ class FakeRoutine implements RoutineInterface
* "ahoy": will log some nonsense and then drop job into status:"need_job_config" to force it back to the job config routine. * "ahoy": will log some nonsense and then drop job into status:"need_job_config" to force it back to the job config routine.
* "final": will do some logging, sleep for 10 seconds and then finish. Generates 5 random transactions. * "final": will do some logging, sleep for 10 seconds and then finish. Generates 5 random transactions.
* *
* @return void
* @throws FireflyException * @throws FireflyException
* *
* @return void
*/ */
public function run(): void public function run(): void
{ {

View File

@ -30,6 +30,7 @@ use Log;
/** /**
* Class FileRoutine * Class FileRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -33,6 +33,7 @@ use Illuminate\Support\Facades\Log;
/** /**
* *
* Class FinTSRoutine * Class FinTSRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -27,6 +27,7 @@ use FireflyIII\Models\ImportJob;
/** /**
* Interface RoutineInterface * Interface RoutineInterface
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -32,6 +32,7 @@ use Log;
/** /**
* Class SpectreRoutine * Class SpectreRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -34,6 +34,7 @@ use Log;
/** /**
* Class YnabRoutine * Class YnabRoutine
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class AbnAmroDescription. * Class AbnAmroDescription.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@ -81,7 +82,7 @@ class AbnAmroDescription implements SpecificInterface
// If the description could not be parsed, specify an unknown opposing // If the description could not be parsed, specify an unknown opposing
// account, as an opposing account is required // account, as an opposing account is required
if (!$parsed) { if (!$parsed) {
$this->row[8] = (string)trans('firefly.unknown'); // opposing-account-name $this->row[8] = (string) trans('firefly.unknown'); // opposing-account-name
} }
return $this->row; return $this->row;

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class Belfius. * Class Belfius.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@ -56,19 +57,6 @@ class Belfius implements SpecificInterface
return 'import.specific_belfius_name'; return 'import.specific_belfius_name';
} }
/**
* Run the fix.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return Belfius::processRecurringTransactionDescription($row);
}
/** /**
* Fixes the description for outgoing recurring transactions so doubles can be detected when the equivalent incoming * Fixes the description for outgoing recurring transactions so doubles can be detected when the equivalent incoming
* transaction is imported for another bank account. * transaction is imported for another bank account.
@ -82,7 +70,7 @@ class Belfius implements SpecificInterface
} }
$opposingAccountName = $row[5]; $opposingAccountName = $row[5];
$description = $row[14]; $description = $row[14];
preg_match('/DOORLOPENDE OPDRACHT.*\s+' . preg_quote($opposingAccountName, '/') . '\s+(.+)\s+REF.\s*:/', $description, $matches); preg_match('/DOORLOPENDE OPDRACHT.*\s+' . preg_quote($opposingAccountName, '/') . '\s+(.+)\s+REF.\s*:/', $description, $matches);
@ -92,4 +80,17 @@ class Belfius implements SpecificInterface
return $row; return $row;
} }
/**
* Run the fix.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return Belfius::processRecurringTransactionDescription($row);
}
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class IngBelgium. * Class IngBelgium.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@ -55,33 +56,26 @@ class IngBelgium implements SpecificInterface
} }
/** /**
* Run the specific code. * Gets the description from the transaction details and makes sure structured descriptions are in the
* * "+++090/9337/55493+++" format.
* @param array $row
*
* @return array
* *
* @return string the description
*/ */
public function run(array $row): array protected static function description(string $transactionDetails): string
{ {
return IngBelgium::processTransactionDetails($row); $description = IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Mededeling:\s*(.+)$/');
return IngBelgium::convertStructuredDescriptionToProperFormat($description);
} }
/** /**
* Gets the description and opposing account information (IBAN and name) from the transaction details and adds * Gets the opposing account's IBAN from the transaction details.
* them to the row of data.
* *
* @return array the row containing the description and opposing account's IBAN * @return string the opposing account's IBAN
*/ */
protected static function processTransactionDetails(array $row): array protected static function opposingAccountIban(string $transactionDetails): string
{ {
if(isset($row[9])) { return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/');
$transactionDetails = $row[9];
$row[11] = IngBelgium::opposingAccountName($transactionDetails);
$row[12] = IngBelgium::opposingAccountIban($transactionDetails);
$row[13] = IngBelgium::description($transactionDetails);
}
return $row;
} }
/** /**
@ -96,39 +90,36 @@ class IngBelgium implements SpecificInterface
} }
/** /**
* Gets the opposing account's IBAN from the transaction details. * Gets the description and opposing account information (IBAN and name) from the transaction details and adds
* them to the row of data.
* *
* @return string the opposing account's IBAN * @return array the row containing the description and opposing account's IBAN
*/ */
protected static function opposingAccountIban(string $transactionDetails): string protected static function processTransactionDetails(array $row): array
{ {
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/'); if (isset($row[9])) {
} $transactionDetails = $row[9];
$row[11] = IngBelgium::opposingAccountName($transactionDetails);
$row[12] = IngBelgium::opposingAccountIban($transactionDetails);
$row[13] = IngBelgium::description($transactionDetails);
}
/** return $row;
* Gets the description from the transaction details and makes sure structured descriptions are in the
* "+++090/9337/55493+++" format.
*
* @return string the description
*/
protected static function description(string $transactionDetails): string
{
$description = IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Mededeling:\s*(.+)$/');
return IngBelgium::convertStructuredDescriptionToProperFormat($description);
} }
private static function convertStructuredDescriptionToProperFormat(string $description): string private static function convertStructuredDescriptionToProperFormat(string $description): string
{ {
preg_match('/^\*\*\*(\d{3}\/\d{4}\/\d{5})\*\*\*$/', $description, $matches); preg_match('/^\*\*\*(\d{3}\/\d{4}\/\d{5})\*\*\*$/', $description, $matches);
if(isset($matches[1])) { if (isset($matches[1])) {
return '+++' . $matches[1] . '+++'; return '+++' . $matches[1] . '+++';
} }
return $description; return $description;
} }
private static function parseInformationFromTransactionDetails(string $transactionDetails, string $regex): string private static function parseInformationFromTransactionDetails(string $transactionDetails, string $regex): string
{ {
if(isset($transactionDetails)) { if (isset($transactionDetails)) {
preg_match($regex, $transactionDetails, $matches); preg_match($regex, $transactionDetails, $matches);
if (isset($matches[1])) { if (isset($matches[1])) {
return trim($matches[1]); return trim($matches[1]);
@ -137,4 +128,17 @@ class IngBelgium implements SpecificInterface
return ''; return '';
} }
/**
* Run the specific code.
*
* @param array $row
*
* @return array
*
*/
public function run(array $row): array
{
return IngBelgium::processTransactionDetails($row);
}
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class IngDescription. * Class IngDescription.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
* *
@ -106,11 +107,14 @@ class IngDescription implements SpecificInterface
} }
/** /**
* Remove "Omschrijving" (and NOT its value) from the description. * Move "Valutadatum" from the description to new column.
*/ */
protected function removeIngDescription(): void protected function moveValutadatumDescription(): void
{ {
$this->row[8] = preg_replace('/Omschrijving: /', '', $this->row[8]); $matches = [];
preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches);
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
} }
/** /**
@ -123,6 +127,14 @@ class IngDescription implements SpecificInterface
$this->row[8] = preg_replace('/\sIBAN:\s' . $this->row[3] . '/', '', $this->row[8]); $this->row[8] = preg_replace('/\sIBAN:\s' . $this->row[3] . '/', '', $this->row[8]);
} }
/**
* Remove "Omschrijving" (and NOT its value) from the description.
*/
protected function removeIngDescription(): void
{
$this->row[8] = preg_replace('/Omschrijving: /', '', $this->row[8]);
}
/** /**
* Remove "Naam" (and its value) from the description. * Remove "Naam" (and its value) from the description.
*/ */
@ -131,31 +143,20 @@ class IngDescription implements SpecificInterface
$this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]); $this->row[8] = preg_replace('/Naam:.*?([a-zA-Z\/]+:)/', '$1', $this->row[8]);
} }
/**
* Move "Valutadatum" from the description to new column.
*/
protected function moveValutadatumDescription(): void
{
$matches = array();
preg_match('/Valutadatum: ([0-9-]+)/', $this->row[8], $matches);
$this->row[9] = date("Ymd", strtotime($matches[1]));
$this->row[8] = preg_replace('/Valutadatum: [0-9-]+/', '', $this->row[8]);
}
/** /**
* Move savings account number to column 1 and name to column 3. * Move savings account number to column 1 and name to column 3.
*/ */
private function MoveSavingsAccount(): void private function MoveSavingsAccount(): void
{ {
$matches = array(); $matches = [];
if ('' === (string)$this->row[3]) { if ('' === (string) $this->row[3]) {
if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) { if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]); $matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name $this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number $this->row[3] = $matches[3]; // Savings account number
$this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([0-9]+)/', '', $this->row[8]); // Remove the savings account content from description $this->row[8] = preg_replace('/(Naar|Van) (.*rekening) ([0-9]+)/', '', $this->row[8]); // Remove the savings account content from description
} elseif (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[1], $matches)) { } elseif (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[1], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]); $matches[3] = sprintf("%010d", $matches[3]);
$this->row[1] = $matches[2]; // Savings account name $this->row[1] = $matches[2]; // Savings account name
$this->row[3] = $matches[3]; // Savings account number $this->row[3] = $matches[3]; // Savings account number
} }

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class PresidentsChoice. * Class PresidentsChoice.
*
* @deprecated * @deprecated
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Class SnsDescription. * Class SnsDescription.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @deprecated * @deprecated
*/ */

View File

@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/** /**
* Interface SpecificInterface. * Interface SpecificInterface.
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @deprecated * @deprecated
*/ */

View File

@ -32,17 +32,14 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\TransactionRules\Engine\RuleEngine; use FireflyIII\TransactionRules\Engine\RuleEngine;
use FireflyIII\TransactionRules\Processor;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log; use Log;
@ -51,6 +48,7 @@ use Log;
* Creates new transactions based on arrays. * Creates new transactions based on arrays.
* *
* Class ImportArrayStorage * Class ImportArrayStorage
*
* @codeCoverageIgnore * @codeCoverageIgnore
* @deprecated * @deprecated
* *
@ -107,8 +105,8 @@ class ImportArrayStorage
* - Link to tag * - Link to tag
* - Run rules (if set to) * - Run rules (if set to)
* *
* @return Collection
* @throws FireflyException * @throws FireflyException
* @return Collection
*/ */
public function store(): Collection public function store(): Collection
{ {
@ -133,7 +131,7 @@ class ImportArrayStorage
app('preferences')->mark(); app('preferences')->mark();
// email about this: // email about this:
event(new RequestedReportOnJournals((int)$this->importJob->user_id, $collection)); event(new RequestedReportOnJournals((int) $this->importJob->user_id, $collection));
return $collection; return $collection;
} }
@ -218,7 +216,7 @@ class ImportArrayStorage
$hash = $this->getHash($transaction); $hash = $this->getHash($transaction);
$existingId = $this->hashExists($hash); $existingId = $this->hashExists($hash);
if (null !== $existingId) { if (null !== $existingId) {
$message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]); $message = (string) trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$this->logDuplicateObject($transaction, $existingId); $this->logDuplicateObject($transaction, $existingId);
$this->repository->addErrorMessage($this->importJob, $message); $this->repository->addErrorMessage($this->importJob, $message);
@ -227,7 +225,7 @@ class ImportArrayStorage
// do transfer detection: // do transfer detection:
if ($this->checkForTransfers && $this->transferExists($transaction)) { if ($this->checkForTransfers && $this->transferExists($transaction)) {
$message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]); $message = (string) trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]);
$this->logDuplicateTransfer($transaction); $this->logDuplicateTransfer($transaction);
$this->repository->addErrorMessage($this->importJob, $message); $this->repository->addErrorMessage($this->importJob, $message);
@ -321,7 +319,7 @@ class ImportArrayStorage
} }
Log::info(sprintf('Found a transaction journal with an existing hash: %s', $hash)); Log::info(sprintf('Found a transaction journal with an existing hash: %s', $hash));
return (int)$entry->transaction_journal_id; return (int) $entry->transaction_journal_id;
} }
/** /**
@ -338,7 +336,7 @@ class ImportArrayStorage
$repository = app(TagRepositoryInterface::class); $repository = app(TagRepositoryInterface::class);
$repository->setUser($this->importJob->user); $repository->setUser($this->importJob->user);
$data = [ $data = [
'tag' => (string)trans('import.import_with_key', ['key' => $this->importJob->key]), 'tag' => (string) trans('import.import_with_key', ['key' => $this->importJob->key]),
'date' => new Carbon, 'date' => new Carbon,
'description' => null, 'description' => null,
'latitude' => null, 'latitude' => null,
@ -475,9 +473,9 @@ class ImportArrayStorage
/** /**
* Store array as journals. * Store array as journals.
* *
* @return Collection
* @throws FireflyException * @throws FireflyException
* *
* @return Collection
*/ */
private function storeGroupArray(): Collection private function storeGroupArray(): Collection
{ {
@ -531,21 +529,21 @@ class ImportArrayStorage
// get the amount: // get the amount:
/** @noinspection UnnecessaryCastingInspection */ /** @noinspection UnnecessaryCastingInspection */
$amount = (string)($transaction['amount'] ?? '0'); $amount = (string) ($transaction['amount'] ?? '0');
if (bccomp($amount, '0') === -1) { if (bccomp($amount, '0') === -1) {
$amount = bcmul($amount, '-1'); // @codeCoverageIgnore $amount = bcmul($amount, '-1'); // @codeCoverageIgnore
} }
// get the description: // get the description:
//$description = '' === (string)$transaction['description'] ? $transaction['description'] : $transaction['description']; //$description = '' === (string)$transaction['description'] ? $transaction['description'] : $transaction['description'];
$description = (string)$transaction['description']; $description = (string) $transaction['description'];
// get the source and destination ID's: // get the source and destination ID's:
$transactionSourceIDs = [(int)$transaction['source_id'], (int)$transaction['destination_id']]; $transactionSourceIDs = [(int) $transaction['source_id'], (int) $transaction['destination_id']];
sort($transactionSourceIDs); sort($transactionSourceIDs);
// get the source and destination names: // get the source and destination names:
$transactionSourceNames = [(string)$transaction['source_name'], (string)$transaction['destination_name']]; $transactionSourceNames = [(string) $transaction['source_name'], (string) $transaction['destination_name']];
sort($transactionSourceNames); sort($transactionSourceNames);
// then loop all transfers: // then loop all transfers:
@ -587,7 +585,7 @@ class ImportArrayStorage
Log::debug(sprintf('Comparison is a hit! (%s)', $hits)); Log::debug(sprintf('Comparison is a hit! (%s)', $hits));
// compare source and destination id's // compare source and destination id's
$transferSourceIDs = [(int)$transfer['source_account_id'], (int)$transfer['destination_account_id']]; $transferSourceIDs = [(int) $transfer['source_account_id'], (int) $transfer['destination_account_id']];
sort($transferSourceIDs); sort($transferSourceIDs);
/** @noinspection DisconnectedForeachInstructionInspection */ /** @noinspection DisconnectedForeachInstructionInspection */
Log::debug('Comparing current transaction source+dest IDs', $transactionSourceIDs); Log::debug('Comparing current transaction source+dest IDs', $transactionSourceIDs);
@ -602,7 +600,7 @@ class ImportArrayStorage
unset($transferSourceIDs); unset($transferSourceIDs);
// compare source and destination names // compare source and destination names
$transferSource = [(string)($transfer['source_account_name'] ?? ''), (string)($transfer['destination_account_name'] ?? '')]; $transferSource = [(string) ($transfer['source_account_name'] ?? ''), (string) ($transfer['destination_account_name'] ?? '')];
sort($transferSource); sort($transferSource);
/** @noinspection DisconnectedForeachInstructionInspection */ /** @noinspection DisconnectedForeachInstructionInspection */
Log::debug('Comparing current transaction source+dest names', $transactionSourceNames); Log::debug('Comparing current transaction source+dest names', $transactionSourceNames);