From a941519db5ebfc29aac96c242c73eae72fe71115 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 22 Jul 2018 15:08:56 +0200 Subject: [PATCH] Improve code quality. --- app/Import/Converter/Amount.php | 3 +++ app/Import/Converter/AmountCredit.php | 2 ++ app/Import/Converter/AmountDebit.php | 2 ++ app/Import/Converter/ConverterInterface.php | 4 +++ app/Import/Converter/INGDebitCredit.php | 2 ++ app/Import/Converter/RabobankDebitCredit.php | 2 ++ .../JobConfiguration/BunqJobConfiguration.php | 10 +++++--- .../JobConfiguration/FakeJobConfiguration.php | 10 ++++++-- .../JobConfiguration/FileJobConfiguration.php | 10 ++++++-- .../JobConfigurationInterface.php | 2 ++ .../SpectreJobConfiguration.php | 16 ++++++------ app/Import/Mapper/AssetAccountIbans.php | 2 ++ app/Import/Mapper/AssetAccounts.php | 2 ++ app/Import/Mapper/Bills.php | 2 ++ app/Import/Mapper/Budgets.php | 2 ++ app/Import/Mapper/Categories.php | 2 ++ app/Import/Mapper/MapperInterface.php | 2 ++ app/Import/Mapper/OpposingAccountIbans.php | 1 + app/Import/Mapper/OpposingAccounts.php | 2 ++ app/Import/Mapper/Tags.php | 2 ++ app/Import/Mapper/TransactionCurrencies.php | 2 ++ .../PreProcessorInterface.php | 2 ++ app/Import/MapperPreProcess/TagsComma.php | 2 ++ app/Import/MapperPreProcess/TagsSpace.php | 2 ++ .../Prerequisites/BunqPrerequisites.php | 20 +++++++++++---- .../Prerequisites/FakePrerequisites.php | 6 ++++- .../Prerequisites/FilePrerequisites.php | 3 ++- .../Prerequisites/SpectrePrerequisites.php | 6 ++++- app/Import/Routine/BunqRoutine.php | 7 +++--- app/Import/Routine/FakeRoutine.php | 9 +++++-- app/Import/Routine/FileRoutine.php | 6 +++-- app/Import/Routine/RoutineInterface.php | 2 ++ app/Import/Routine/SpectreRoutine.php | 9 +++++-- app/Import/Specifics/AbnAmroDescription.php | 20 ++++++++++++--- app/Import/Specifics/IngDescription.php | 16 +++++++++--- app/Import/Specifics/PresidentsChoice.php | 10 ++++++-- app/Import/Specifics/RabobankDescription.php | 15 +++++++++-- app/Import/Specifics/SnsDescription.php | 10 ++++++-- app/Import/Specifics/SpecificInterface.php | 6 +++++ app/Import/Storage/ImportArrayStorage.php | 25 ++++++++++++++----- .../Journal/JournalRepository.php | 4 +-- 41 files changed, 210 insertions(+), 52 deletions(-) diff --git a/app/Import/Converter/Amount.php b/app/Import/Converter/Amount.php index 1b828c6663..417e1ac71f 100644 --- a/app/Import/Converter/Amount.php +++ b/app/Import/Converter/Amount.php @@ -183,6 +183,9 @@ class Amount implements ConverterInterface } /** + * Replaces other characters like thousand separators with nothing to make the decimal separator the only special + * character in the string. + * * @param string $decimal * @param string $value * diff --git a/app/Import/Converter/AmountCredit.php b/app/Import/Converter/AmountCredit.php index f57220860f..877a68a0a8 100644 --- a/app/Import/Converter/AmountCredit.php +++ b/app/Import/Converter/AmountCredit.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\Converter; class AmountCredit implements ConverterInterface { /** + * Convert an amount, always return positive. + * * @param $value * * @return string diff --git a/app/Import/Converter/AmountDebit.php b/app/Import/Converter/AmountDebit.php index 46162ec484..f071569920 100644 --- a/app/Import/Converter/AmountDebit.php +++ b/app/Import/Converter/AmountDebit.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\Converter; class AmountDebit implements ConverterInterface { /** + * Convert amount, always return positive. + * * @param $value * * @return string diff --git a/app/Import/Converter/ConverterInterface.php b/app/Import/Converter/ConverterInterface.php index 40c51884cf..903929ba1d 100644 --- a/app/Import/Converter/ConverterInterface.php +++ b/app/Import/Converter/ConverterInterface.php @@ -28,6 +28,10 @@ namespace FireflyIII\Import\Converter; interface ConverterInterface { /** + * Convert a value. + * + * @return mixed + * * @param $value */ public function convert($value); diff --git a/app/Import/Converter/INGDebitCredit.php b/app/Import/Converter/INGDebitCredit.php index 4148c7d2ea..6b741f23e3 100644 --- a/app/Import/Converter/INGDebitCredit.php +++ b/app/Import/Converter/INGDebitCredit.php @@ -30,6 +30,8 @@ use Log; class INGDebitCredit implements ConverterInterface { /** + * Convert Af or Bij to correct integer values. + * * @param $value * * @return int diff --git a/app/Import/Converter/RabobankDebitCredit.php b/app/Import/Converter/RabobankDebitCredit.php index 764a7f907e..921056eaf3 100644 --- a/app/Import/Converter/RabobankDebitCredit.php +++ b/app/Import/Converter/RabobankDebitCredit.php @@ -30,6 +30,8 @@ use Log; class RabobankDebitCredit implements ConverterInterface { /** + * Convert D or A to integer values. + * * @param $value * * @return int diff --git a/app/Import/JobConfiguration/BunqJobConfiguration.php b/app/Import/JobConfiguration/BunqJobConfiguration.php index 9ea6382b4d..8a91eb8105 100644 --- a/app/Import/JobConfiguration/BunqJobConfiguration.php +++ b/app/Import/JobConfiguration/BunqJobConfiguration.php @@ -37,11 +37,11 @@ use Log; */ class BunqJobConfiguration implements JobConfigurationInterface { - /** @var BunqJobConfigurationInterface */ + /** @var BunqJobConfigurationInterface Bunq job interface */ private $handler; - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -88,6 +88,8 @@ class BunqJobConfiguration implements JobConfigurationInterface } /** + * Set import job. + * * @param ImportJob $importJob * * @throws FireflyException @@ -101,6 +103,8 @@ class BunqJobConfiguration implements JobConfigurationInterface } /** + * Get correct handler. + * * @return BunqJobConfigurationInterface * @throws FireflyException */ diff --git a/app/Import/JobConfiguration/FakeJobConfiguration.php b/app/Import/JobConfiguration/FakeJobConfiguration.php index 751cacf721..6936768b78 100644 --- a/app/Import/JobConfiguration/FakeJobConfiguration.php +++ b/app/Import/JobConfiguration/FakeJobConfiguration.php @@ -32,10 +32,10 @@ use Illuminate\Support\MessageBag; */ class FakeJobConfiguration implements JobConfigurationInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -69,6 +69,8 @@ class FakeJobConfiguration implements JobConfigurationInterface * @param array $data * * @return MessageBag + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function configureJob(array $data): MessageBag { @@ -125,6 +127,8 @@ class FakeJobConfiguration implements JobConfigurationInterface * Returns the view of the next step in the job configuration. * * @return string + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getNextView(): string { @@ -151,6 +155,8 @@ class FakeJobConfiguration implements JobConfigurationInterface } /** + * Set import job. + * * @param ImportJob $importJob */ public function setImportJob(ImportJob $importJob): void diff --git a/app/Import/JobConfiguration/FileJobConfiguration.php b/app/Import/JobConfiguration/FileJobConfiguration.php index a40bc47bf7..e240dd974e 100644 --- a/app/Import/JobConfiguration/FileJobConfiguration.php +++ b/app/Import/JobConfiguration/FileJobConfiguration.php @@ -40,9 +40,9 @@ use Illuminate\Support\MessageBag; */ class FileJobConfiguration implements JobConfigurationInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -91,6 +91,8 @@ class FileJobConfiguration implements JobConfigurationInterface * * @throws FireflyException * @return string + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getNextView(): string { @@ -116,6 +118,8 @@ class FileJobConfiguration implements JobConfigurationInterface } /** + * Set import job. + * * @param ImportJob $importJob */ public function setImportJob(ImportJob $importJob): void @@ -130,6 +134,8 @@ class FileJobConfiguration implements JobConfigurationInterface * * @return FileConfigurationInterface * @throws FireflyException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function getConfigurationObject(): FileConfigurationInterface { diff --git a/app/Import/JobConfiguration/JobConfigurationInterface.php b/app/Import/JobConfiguration/JobConfigurationInterface.php index 0560240b17..4ff58ae133 100644 --- a/app/Import/JobConfiguration/JobConfigurationInterface.php +++ b/app/Import/JobConfiguration/JobConfigurationInterface.php @@ -62,6 +62,8 @@ interface JobConfigurationInterface public function getNextView(): string; /** + * Set import job. + * * @param ImportJob $importJob */ public function setImportJob(ImportJob $importJob): void; diff --git a/app/Import/JobConfiguration/SpectreJobConfiguration.php b/app/Import/JobConfiguration/SpectreJobConfiguration.php index 1251ebf6f4..2569159a7f 100644 --- a/app/Import/JobConfiguration/SpectreJobConfiguration.php +++ b/app/Import/JobConfiguration/SpectreJobConfiguration.php @@ -26,14 +26,10 @@ namespace FireflyIII\Import\JobConfiguration; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\ImportJob; use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; -use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedConfigHandler; use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticatedHandler; -use FireflyIII\Support\Import\JobConfiguration\Spectre\AuthenticateHandler; -use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccount; use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseAccountsHandler; use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler; use FireflyIII\Support\Import\JobConfiguration\Spectre\DoAuthenticateHandler; -use FireflyIII\Support\Import\JobConfiguration\Spectre\NewConfig; use FireflyIII\Support\Import\JobConfiguration\Spectre\NewSpectreJobHandler; use FireflyIII\Support\Import\JobConfiguration\Spectre\SpectreJobConfigurationInterface; use Illuminate\Support\MessageBag; @@ -44,11 +40,11 @@ use Log; */ class SpectreJobConfiguration implements JobConfigurationInterface { - /** @var SpectreJobConfigurationInterface */ + /** @var SpectreJobConfigurationInterface The job handler. */ private $handler; - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -95,6 +91,8 @@ class SpectreJobConfiguration implements JobConfigurationInterface } /** + * Set the import job. + * * @param ImportJob $importJob * * @throws FireflyException @@ -108,8 +106,12 @@ class SpectreJobConfiguration implements JobConfigurationInterface } /** + * Get correct handler. + * * @return SpectreJobConfigurationInterface * @throws FireflyException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function getHandler(): SpectreJobConfigurationInterface { diff --git a/app/Import/Mapper/AssetAccountIbans.php b/app/Import/Mapper/AssetAccountIbans.php index ce9585fc44..f79415e63b 100644 --- a/app/Import/Mapper/AssetAccountIbans.php +++ b/app/Import/Mapper/AssetAccountIbans.php @@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; class AssetAccountIbans implements MapperInterface { /** + * Get map of asset accounts. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/AssetAccounts.php b/app/Import/Mapper/AssetAccounts.php index c5754a3717..e1062074a0 100644 --- a/app/Import/Mapper/AssetAccounts.php +++ b/app/Import/Mapper/AssetAccounts.php @@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; class AssetAccounts implements MapperInterface { /** + * Get map of asset accounts. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/Bills.php b/app/Import/Mapper/Bills.php index 8e8c8efa2e..dc0f6a3598 100644 --- a/app/Import/Mapper/Bills.php +++ b/app/Import/Mapper/Bills.php @@ -31,6 +31,8 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface; class Bills implements MapperInterface { /** + * Get map of bills. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/Budgets.php b/app/Import/Mapper/Budgets.php index d8399dce85..f69e7ec23e 100644 --- a/app/Import/Mapper/Budgets.php +++ b/app/Import/Mapper/Budgets.php @@ -31,6 +31,8 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; class Budgets implements MapperInterface { /** + * Get map of budgets. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/Categories.php b/app/Import/Mapper/Categories.php index bb840743e5..6c55aa53e8 100644 --- a/app/Import/Mapper/Categories.php +++ b/app/Import/Mapper/Categories.php @@ -31,6 +31,8 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface; class Categories implements MapperInterface { /** + * Get map of categories. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/MapperInterface.php b/app/Import/Mapper/MapperInterface.php index 9446babdd2..5ac042611e 100644 --- a/app/Import/Mapper/MapperInterface.php +++ b/app/Import/Mapper/MapperInterface.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\Mapper; interface MapperInterface { /** + * Get map of objects. + * * @return array */ public function getMap(): array; diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php index 3eae583064..ad15bf94e6 100644 --- a/app/Import/Mapper/OpposingAccountIbans.php +++ b/app/Import/Mapper/OpposingAccountIbans.php @@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; class OpposingAccountIbans implements MapperInterface { /** + * Get map of opposing accounts. * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/OpposingAccounts.php b/app/Import/Mapper/OpposingAccounts.php index e887078758..424cdafb37 100644 --- a/app/Import/Mapper/OpposingAccounts.php +++ b/app/Import/Mapper/OpposingAccounts.php @@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface; class OpposingAccounts implements MapperInterface { /** + * Get map of opposing accounts. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/Tags.php b/app/Import/Mapper/Tags.php index e81fb2a2be..90ce4b8a41 100644 --- a/app/Import/Mapper/Tags.php +++ b/app/Import/Mapper/Tags.php @@ -31,6 +31,8 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface; class Tags implements MapperInterface { /** + * Get map of tags. + * * @return array */ public function getMap(): array diff --git a/app/Import/Mapper/TransactionCurrencies.php b/app/Import/Mapper/TransactionCurrencies.php index b0eaf956bd..44c7ba5be8 100644 --- a/app/Import/Mapper/TransactionCurrencies.php +++ b/app/Import/Mapper/TransactionCurrencies.php @@ -30,6 +30,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; class TransactionCurrencies implements MapperInterface { /** + * Get map of currencies. + * * @return array */ public function getMap(): array diff --git a/app/Import/MapperPreProcess/PreProcessorInterface.php b/app/Import/MapperPreProcess/PreProcessorInterface.php index 5346d5dddc..b577f605a6 100644 --- a/app/Import/MapperPreProcess/PreProcessorInterface.php +++ b/app/Import/MapperPreProcess/PreProcessorInterface.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess; interface PreProcessorInterface { /** + * Run preprocessor. + * * @param string $value * * @return array diff --git a/app/Import/MapperPreProcess/TagsComma.php b/app/Import/MapperPreProcess/TagsComma.php index 294026c090..1c54595a7a 100644 --- a/app/Import/MapperPreProcess/TagsComma.php +++ b/app/Import/MapperPreProcess/TagsComma.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess; class TagsComma implements PreProcessorInterface { /** + * Explode and filter list of comma separated tags. + * * @param string $value * * @return array diff --git a/app/Import/MapperPreProcess/TagsSpace.php b/app/Import/MapperPreProcess/TagsSpace.php index 63e949e5d7..92530ee887 100644 --- a/app/Import/MapperPreProcess/TagsSpace.php +++ b/app/Import/MapperPreProcess/TagsSpace.php @@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess; class TagsSpace implements PreProcessorInterface { /** + * Explode and filter list of space separated tags. + * * @param string $value * * @return array diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.php index 21334ced35..1aeecf1499 100644 --- a/app/Import/Prerequisites/BunqPrerequisites.php +++ b/app/Import/Prerequisites/BunqPrerequisites.php @@ -36,13 +36,14 @@ use Log; */ class BunqPrerequisites implements PrerequisitesInterface { - /** @var User */ + /** @var User The current user */ private $user; /** - * @codeCoverageIgnore * Returns view name that allows user to fill in prerequisites. * + * @codeCoverageIgnore + * * @return string */ public function getView(): string @@ -86,10 +87,11 @@ class BunqPrerequisites implements PrerequisitesInterface } /** - * @codeCoverageIgnore * Set the user for this Prerequisites-routine. Class is expected to implement and save this. * * @param User $user + * + * @codeCoverageIgnore */ public function setUser(User $user): void { @@ -104,6 +106,7 @@ class BunqPrerequisites implements PrerequisitesInterface * @param array $data * * @return MessageBag + * */ public function storePrerequisites(array $data): MessageBag { @@ -112,7 +115,6 @@ class BunqPrerequisites implements PrerequisitesInterface Log::debug('Storing bunq API key'); app('preferences')->setForUser($this->user, 'bunq_api_key', $apiKey); app('preferences')->setForUser($this->user, 'bunq_external_ip', $externalIP); - $environment = $this->getBunqEnvironment(); $deviceDescription = 'Firefly III v' . config('firefly.version'); $permittedIps = [$externalIP]; @@ -147,8 +149,10 @@ class BunqPrerequisites implements PrerequisitesInterface } /** - * @codeCoverageIgnore + * Get correct bunq environment. + * * @return BunqEnumApiEnvironmentType + * @codeCoverageIgnore */ private function getBunqEnvironment(): BunqEnumApiEnvironmentType { @@ -164,6 +168,8 @@ class BunqPrerequisites implements PrerequisitesInterface } /** + * Check if we have API context. + * * @return bool */ private function hasApiContext(): bool @@ -180,6 +186,8 @@ class BunqPrerequisites implements PrerequisitesInterface } /** + * Check if we have the API key. + * * @return bool */ private function hasApiKey(): bool @@ -196,6 +204,8 @@ class BunqPrerequisites implements PrerequisitesInterface } /** + * Checks if we have an external IP. + * * @return bool */ private function hasExternalIP(): bool diff --git a/app/Import/Prerequisites/FakePrerequisites.php b/app/Import/Prerequisites/FakePrerequisites.php index a5565d9c5d..39dbec4762 100644 --- a/app/Import/Prerequisites/FakePrerequisites.php +++ b/app/Import/Prerequisites/FakePrerequisites.php @@ -32,7 +32,7 @@ use Illuminate\Support\MessageBag; */ class FakePrerequisites implements PrerequisitesInterface { - /** @var User */ + /** @var User The current user */ private $user; /** @@ -87,6 +87,8 @@ class FakePrerequisites implements PrerequisitesInterface } /** + * Store fake prerequisites. + * * @param array $data * * @return MessageBag @@ -107,6 +109,8 @@ class FakePrerequisites implements PrerequisitesInterface } /** + * Check if we have an API key. + * * @return bool */ private function hasApiKey(): bool diff --git a/app/Import/Prerequisites/FilePrerequisites.php b/app/Import/Prerequisites/FilePrerequisites.php index c9200489e3..14109b0fb3 100644 --- a/app/Import/Prerequisites/FilePrerequisites.php +++ b/app/Import/Prerequisites/FilePrerequisites.php @@ -26,9 +26,10 @@ use FireflyIII\User; use Illuminate\Support\MessageBag; /** - * @codeCoverageIgnore * * This class contains all the routines necessary to import from a file. Hint: there are none. + * + * @codeCoverageIgnore */ class FilePrerequisites implements PrerequisitesInterface { diff --git a/app/Import/Prerequisites/SpectrePrerequisites.php b/app/Import/Prerequisites/SpectrePrerequisites.php index 239e3f274b..8cd4616ae9 100644 --- a/app/Import/Prerequisites/SpectrePrerequisites.php +++ b/app/Import/Prerequisites/SpectrePrerequisites.php @@ -32,7 +32,7 @@ use Log; */ class SpectrePrerequisites implements PrerequisitesInterface { - /** @var User */ + /** @var User The current user */ private $user; /** @@ -156,6 +156,8 @@ class SpectrePrerequisites implements PrerequisitesInterface } /** + * Check if we have the App ID. + * * @return bool */ private function hasAppId(): bool @@ -172,6 +174,8 @@ class SpectrePrerequisites implements PrerequisitesInterface } /** + * Check if we have the secret. + * * @return bool */ private function hasSecret(): bool diff --git a/app/Import/Routine/BunqRoutine.php b/app/Import/Routine/BunqRoutine.php index 0f29d089f8..d450655345 100644 --- a/app/Import/Routine/BunqRoutine.php +++ b/app/Import/Routine/BunqRoutine.php @@ -35,10 +35,10 @@ use Log; */ class BunqRoutine implements RoutineInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -63,7 +63,6 @@ class BunqRoutine implements RoutineInterface $handler = app(StageNewHandler::class); $handler->setImportJob($this->importJob); $handler->run(); - // make user choose accounts to import from. $this->repository->setStage($this->importJob, 'choose-accounts'); $this->repository->setStatus($this->importJob, 'need_job_config'); @@ -91,6 +90,8 @@ class BunqRoutine implements RoutineInterface /** + * Set the import job. + * * @param ImportJob $importJob * * @return void diff --git a/app/Import/Routine/FakeRoutine.php b/app/Import/Routine/FakeRoutine.php index 497fcb93dd..14ed949977 100644 --- a/app/Import/Routine/FakeRoutine.php +++ b/app/Import/Routine/FakeRoutine.php @@ -36,9 +36,9 @@ use Log; */ class FakeRoutine implements RoutineInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -51,6 +51,9 @@ class FakeRoutine implements RoutineInterface * * @return void * @throws FireflyException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function run(): void { @@ -93,6 +96,8 @@ class FakeRoutine implements RoutineInterface } /** + * Set the import job. + * * @param ImportJob $importJob * */ diff --git a/app/Import/Routine/FileRoutine.php b/app/Import/Routine/FileRoutine.php index e88fe64456..c61f7afdac 100644 --- a/app/Import/Routine/FileRoutine.php +++ b/app/Import/Routine/FileRoutine.php @@ -33,9 +33,9 @@ use Log; */ class FileRoutine implements RoutineInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -66,6 +66,8 @@ class FileRoutine implements RoutineInterface } /** + * Set the import job. + * * @param ImportJob $importJob * * @return void diff --git a/app/Import/Routine/RoutineInterface.php b/app/Import/Routine/RoutineInterface.php index aad9c4854a..bb7c4537fb 100644 --- a/app/Import/Routine/RoutineInterface.php +++ b/app/Import/Routine/RoutineInterface.php @@ -40,6 +40,8 @@ interface RoutineInterface public function run(): void; /** + * Set the import job. + * * @param ImportJob $importJob * * @return void diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.php index a35f65b9f4..5bb5a07b53 100644 --- a/app/Import/Routine/SpectreRoutine.php +++ b/app/Import/Routine/SpectreRoutine.php @@ -36,10 +36,10 @@ use Log; class SpectreRoutine implements RoutineInterface { - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; /** @@ -48,6 +48,9 @@ class SpectreRoutine implements RoutineInterface * The final status of the routine must be "provider_finished". * * @throws FireflyException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function run(): void { @@ -108,6 +111,8 @@ class SpectreRoutine implements RoutineInterface } /** + * Set the import job. + * * @param ImportJob $importJob * * @return void diff --git a/app/Import/Specifics/AbnAmroDescription.php b/app/Import/Specifics/AbnAmroDescription.php index 8eab9c29f3..2c4296a119 100644 --- a/app/Import/Specifics/AbnAmroDescription.php +++ b/app/Import/Specifics/AbnAmroDescription.php @@ -32,12 +32,14 @@ namespace FireflyIII\Import\Specifics; */ class AbnAmroDescription implements SpecificInterface { - /** @var array */ + /** @var array The current row. */ public $row; /** - * @codeCoverageIgnore + * Description of this specific fix. + * * @return string + * @codeCoverageIgnore */ public static function getDescription(): string { @@ -45,8 +47,10 @@ class AbnAmroDescription implements SpecificInterface } /** - * @codeCoverageIgnore + * Name of specific fix. + * * @return string + * @codeCoverageIgnore */ public static function getName(): string { @@ -54,9 +58,13 @@ class AbnAmroDescription implements SpecificInterface } /** + * Run the fix. + * * @param array $row * * @return array + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function run(array $row): array { @@ -123,6 +131,9 @@ class AbnAmroDescription implements SpecificInterface * Parses the current description in SEPA format. * * @return bool true if the description is SEPA format, false otherwise + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function parseSepaDescription(): bool { @@ -177,6 +188,9 @@ class AbnAmroDescription implements SpecificInterface * Parses the current description in TRTP format. * * @return bool true if the description is TRTP format, false otherwise + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function parseTRTPDescription(): bool { diff --git a/app/Import/Specifics/IngDescription.php b/app/Import/Specifics/IngDescription.php index 599f22d669..6980105893 100644 --- a/app/Import/Specifics/IngDescription.php +++ b/app/Import/Specifics/IngDescription.php @@ -34,12 +34,14 @@ namespace FireflyIII\Import\Specifics; */ class IngDescription implements SpecificInterface { - /** @var array */ + /** @var array The current row. */ public $row; /** - * @codeCoverageIgnore + * Description of the current specific. + * * @return string + * @codeCoverageIgnore */ public static function getDescription(): string { @@ -47,8 +49,10 @@ class IngDescription implements SpecificInterface } /** - * @codeCoverageIgnore + * Name of the current specific. + * * @return string + * @codeCoverageIgnore */ public static function getName(): string { @@ -56,9 +60,13 @@ class IngDescription implements SpecificInterface } /** + * Run the specific code. + * * @param array $row * * @return array + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function run(array $row): array { @@ -112,7 +120,7 @@ class IngDescription implements SpecificInterface } /** - * + * Copy description to name of opposite account. */ private function copyDescriptionToOpposite(): void { diff --git a/app/Import/Specifics/PresidentsChoice.php b/app/Import/Specifics/PresidentsChoice.php index 2b067305d1..1fa71e1cf2 100644 --- a/app/Import/Specifics/PresidentsChoice.php +++ b/app/Import/Specifics/PresidentsChoice.php @@ -28,8 +28,10 @@ namespace FireflyIII\Import\Specifics; class PresidentsChoice implements SpecificInterface { /** - * @codeCoverageIgnore + * Description of specific. + * * @return string + * @codeCoverageIgnore */ public static function getDescription(): string { @@ -37,8 +39,10 @@ class PresidentsChoice implements SpecificInterface } /** - * @codeCoverageIgnore + * Name of specific. + * * @return string + * @codeCoverageIgnore */ public static function getName(): string { @@ -46,6 +50,8 @@ class PresidentsChoice implements SpecificInterface } /** + * Run this specific. + * * @param array $row * * @return array diff --git a/app/Import/Specifics/RabobankDescription.php b/app/Import/Specifics/RabobankDescription.php index 38b9e33dd3..65ceaf0024 100644 --- a/app/Import/Specifics/RabobankDescription.php +++ b/app/Import/Specifics/RabobankDescription.php @@ -26,12 +26,17 @@ use Log; /** * Class RabobankDescription. + * + * @codeCoverageIgnore + * @deprecated */ class RabobankDescription implements SpecificInterface { /** - * @codeCoverageIgnore + * Description of this specific. + * * @return string + * @codeCoverageIgnore */ public static function getDescription(): string { @@ -39,8 +44,10 @@ class RabobankDescription implements SpecificInterface } /** - * @codeCoverageIgnore + * Name of this specific. + * * @return string + * @codeCoverageIgnore */ public static function getName(): string { @@ -48,9 +55,13 @@ class RabobankDescription implements SpecificInterface } /** + * Run the specific. + * * @param array $row * * @return array + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function run(array $row): array { diff --git a/app/Import/Specifics/SnsDescription.php b/app/Import/Specifics/SnsDescription.php index 3ce3f1499e..3106075555 100644 --- a/app/Import/Specifics/SnsDescription.php +++ b/app/Import/Specifics/SnsDescription.php @@ -28,8 +28,10 @@ namespace FireflyIII\Import\Specifics; class SnsDescription implements SpecificInterface { /** - * @codeCoverageIgnore + * Get description of specific. + * * @return string + * @codeCoverageIgnore */ public static function getDescription(): string { @@ -37,8 +39,10 @@ class SnsDescription implements SpecificInterface } /** - * @codeCoverageIgnore + * Get name of specific. + * * @return string + * @codeCoverageIgnore */ public static function getName(): string { @@ -46,6 +50,8 @@ class SnsDescription implements SpecificInterface } /** + * Run specific. + * * @param array $row * * @return array diff --git a/app/Import/Specifics/SpecificInterface.php b/app/Import/Specifics/SpecificInterface.php index d721f18557..70e028e0b1 100644 --- a/app/Import/Specifics/SpecificInterface.php +++ b/app/Import/Specifics/SpecificInterface.php @@ -28,16 +28,22 @@ namespace FireflyIII\Import\Specifics; interface SpecificInterface { /** + * Get description. + * * @return string */ public static function getDescription(): string; /** + * Get name. + * * @return string */ public static function getName(): string; /** + * Run specific. + * * @param array $row * * @return array diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index e71e4986b1..666593e238 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -46,18 +46,20 @@ use Log; * Creates new transactions based upon arrays. Will first check the array for duplicates. * * Class ImportArrayStorage + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ImportArrayStorage { - /** @var bool */ + /** @var bool Check for transfers during import. */ private $checkForTransfers = false; - /** @var ImportJob */ + /** @var ImportJob The import job */ private $importJob; /** @var JournalRepositoryInterface */ private $journalRepos; - /** @var ImportJobRepositoryInterface */ + /** @var ImportJobRepositoryInterface Import job repository */ private $repository; - /** @var Collection */ + /** @var Collection The transfers. */ private $transfers; /** @@ -142,6 +144,8 @@ class ImportArrayStorage /** * Count the number of transfers in the array. If this is zero, don't bother checking for double transfers. + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function countTransfers(): void { @@ -156,10 +160,10 @@ class ImportArrayStorage } } if (0 === $count) { - Log::debug('Count is zero.'); + Log::debug('Count is zero, will not check for duplicate transfers.'); } if ($count > 0) { - Log::debug(sprintf('Count is %d', $count)); + Log::debug(sprintf('Count is %d, will check for duplicate transfers.', $count)); $this->checkForTransfers = true; // get users transfers. Needed for comparison. @@ -169,6 +173,8 @@ class ImportArrayStorage } /** + * Get hash of transaction. + * * @param array $transaction * * @throws FireflyException @@ -339,6 +345,9 @@ class ImportArrayStorage * * @return Collection * @throws FireflyException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ private function storeArray(): Collection { @@ -431,6 +440,10 @@ class ImportArrayStorage * @param $transaction * * @return bool + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.NPathComplexity) */ private function transferExists(array $transaction): bool { diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index d5e58f96f6..c3ad238bb9 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -167,8 +167,8 @@ class JournalRepository implements JournalRepositoryInterface Log::debug(sprintf('JSON encoded hash is: %s', $jsonEncode)); Log::debug(sprintf('Hash of hash is: %s', $hashOfHash)); - $result = TransactionJournalMeta - ::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') + $result = TransactionJournalMeta::withTrashed() + ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') ->where('hash', $hashOfHash) ->where('name', 'importHashV2') ->first(['journal_meta.*']);