Improve code quality.

This commit is contained in:
James Cole 2018-07-22 15:08:56 +02:00
parent d4ba014a8a
commit a941519db5
41 changed files with 210 additions and 52 deletions

View File

@ -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 $decimal
* @param string $value * @param string $value
* *

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\Converter;
class AmountCredit implements ConverterInterface class AmountCredit implements ConverterInterface
{ {
/** /**
* Convert an amount, always return positive.
*
* @param $value * @param $value
* *
* @return string * @return string

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\Converter;
class AmountDebit implements ConverterInterface class AmountDebit implements ConverterInterface
{ {
/** /**
* Convert amount, always return positive.
*
* @param $value * @param $value
* *
* @return string * @return string

View File

@ -28,6 +28,10 @@ namespace FireflyIII\Import\Converter;
interface ConverterInterface interface ConverterInterface
{ {
/** /**
* Convert a value.
*
* @return mixed
*
* @param $value * @param $value
*/ */
public function convert($value); public function convert($value);

View File

@ -30,6 +30,8 @@ use Log;
class INGDebitCredit implements ConverterInterface class INGDebitCredit implements ConverterInterface
{ {
/** /**
* Convert Af or Bij to correct integer values.
*
* @param $value * @param $value
* *
* @return int * @return int

View File

@ -30,6 +30,8 @@ use Log;
class RabobankDebitCredit implements ConverterInterface class RabobankDebitCredit implements ConverterInterface
{ {
/** /**
* Convert D or A to integer values.
*
* @param $value * @param $value
* *
* @return int * @return int

View File

@ -37,11 +37,11 @@ use Log;
*/ */
class BunqJobConfiguration implements JobConfigurationInterface class BunqJobConfiguration implements JobConfigurationInterface
{ {
/** @var BunqJobConfigurationInterface */ /** @var BunqJobConfigurationInterface Bunq job interface */
private $handler; private $handler;
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -88,6 +88,8 @@ class BunqJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Set import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @throws FireflyException * @throws FireflyException
@ -101,6 +103,8 @@ class BunqJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Get correct handler.
*
* @return BunqJobConfigurationInterface * @return BunqJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
*/ */

View File

@ -32,10 +32,10 @@ use Illuminate\Support\MessageBag;
*/ */
class FakeJobConfiguration implements JobConfigurationInterface class FakeJobConfiguration implements JobConfigurationInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -69,6 +69,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
* @param array $data * @param array $data
* *
* @return MessageBag * @return MessageBag
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function configureJob(array $data): MessageBag 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. * Returns the view of the next step in the job configuration.
* *
* @return string * @return string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function getNextView(): string public function getNextView(): string
{ {
@ -151,6 +155,8 @@ class FakeJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Set import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
*/ */
public function setImportJob(ImportJob $importJob): void public function setImportJob(ImportJob $importJob): void

View File

@ -40,9 +40,9 @@ use Illuminate\Support\MessageBag;
*/ */
class FileJobConfiguration implements JobConfigurationInterface class FileJobConfiguration implements JobConfigurationInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -91,6 +91,8 @@ class FileJobConfiguration implements JobConfigurationInterface
* *
* @throws FireflyException * @throws FireflyException
* @return string * @return string
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function getNextView(): string public function getNextView(): string
{ {
@ -116,6 +118,8 @@ class FileJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Set import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
*/ */
public function setImportJob(ImportJob $importJob): void public function setImportJob(ImportJob $importJob): void
@ -130,6 +134,8 @@ class FileJobConfiguration implements JobConfigurationInterface
* *
* @return FileConfigurationInterface * @return FileConfigurationInterface
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
private function getConfigurationObject(): FileConfigurationInterface private function getConfigurationObject(): FileConfigurationInterface
{ {

View File

@ -62,6 +62,8 @@ interface JobConfigurationInterface
public function getNextView(): string; public function getNextView(): string;
/** /**
* Set import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
*/ */
public function setImportJob(ImportJob $importJob): void; public function setImportJob(ImportJob $importJob): void;

View File

@ -26,14 +26,10 @@ namespace FireflyIII\Import\JobConfiguration;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ImportJob; use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface; 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\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\ChooseAccountsHandler;
use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler; use FireflyIII\Support\Import\JobConfiguration\Spectre\ChooseLoginHandler;
use FireflyIII\Support\Import\JobConfiguration\Spectre\DoAuthenticateHandler; 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\NewSpectreJobHandler;
use FireflyIII\Support\Import\JobConfiguration\Spectre\SpectreJobConfigurationInterface; use FireflyIII\Support\Import\JobConfiguration\Spectre\SpectreJobConfigurationInterface;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
@ -44,11 +40,11 @@ use Log;
*/ */
class SpectreJobConfiguration implements JobConfigurationInterface class SpectreJobConfiguration implements JobConfigurationInterface
{ {
/** @var SpectreJobConfigurationInterface */ /** @var SpectreJobConfigurationInterface The job handler. */
private $handler; private $handler;
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -95,6 +91,8 @@ class SpectreJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @throws FireflyException * @throws FireflyException
@ -108,8 +106,12 @@ class SpectreJobConfiguration implements JobConfigurationInterface
} }
/** /**
* Get correct handler.
*
* @return SpectreJobConfigurationInterface * @return SpectreJobConfigurationInterface
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
private function getHandler(): SpectreJobConfigurationInterface private function getHandler(): SpectreJobConfigurationInterface
{ {

View File

@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
class AssetAccountIbans implements MapperInterface class AssetAccountIbans implements MapperInterface
{ {
/** /**
* Get map of asset accounts.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
class AssetAccounts implements MapperInterface class AssetAccounts implements MapperInterface
{ {
/** /**
* Get map of asset accounts.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -31,6 +31,8 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
class Bills implements MapperInterface class Bills implements MapperInterface
{ {
/** /**
* Get map of bills.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -31,6 +31,8 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
class Budgets implements MapperInterface class Budgets implements MapperInterface
{ {
/** /**
* Get map of budgets.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -31,6 +31,8 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
class Categories implements MapperInterface class Categories implements MapperInterface
{ {
/** /**
* Get map of categories.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\Mapper;
interface MapperInterface interface MapperInterface
{ {
/** /**
* Get map of objects.
*
* @return array * @return array
*/ */
public function getMap(): array; public function getMap(): array;

View File

@ -32,6 +32,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
class OpposingAccountIbans implements MapperInterface class OpposingAccountIbans implements MapperInterface
{ {
/** /**
* Get map of opposing accounts.
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -32,6 +32,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
class OpposingAccounts implements MapperInterface class OpposingAccounts implements MapperInterface
{ {
/** /**
* Get map of opposing accounts.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -31,6 +31,8 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
class Tags implements MapperInterface class Tags implements MapperInterface
{ {
/** /**
* Get map of tags.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -30,6 +30,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
class TransactionCurrencies implements MapperInterface class TransactionCurrencies implements MapperInterface
{ {
/** /**
* Get map of currencies.
*
* @return array * @return array
*/ */
public function getMap(): array public function getMap(): array

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess;
interface PreProcessorInterface interface PreProcessorInterface
{ {
/** /**
* Run preprocessor.
*
* @param string $value * @param string $value
* *
* @return array * @return array

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess;
class TagsComma implements PreProcessorInterface class TagsComma implements PreProcessorInterface
{ {
/** /**
* Explode and filter list of comma separated tags.
*
* @param string $value * @param string $value
* *
* @return array * @return array

View File

@ -28,6 +28,8 @@ namespace FireflyIII\Import\MapperPreProcess;
class TagsSpace implements PreProcessorInterface class TagsSpace implements PreProcessorInterface
{ {
/** /**
* Explode and filter list of space separated tags.
*
* @param string $value * @param string $value
* *
* @return array * @return array

View File

@ -36,13 +36,14 @@ use Log;
*/ */
class BunqPrerequisites implements PrerequisitesInterface class BunqPrerequisites implements PrerequisitesInterface
{ {
/** @var User */ /** @var User The current user */
private $user; private $user;
/** /**
* @codeCoverageIgnore
* Returns view name that allows user to fill in prerequisites. * Returns view name that allows user to fill in prerequisites.
* *
* @codeCoverageIgnore
*
* @return string * @return string
*/ */
public function getView(): 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. * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
* *
* @param User $user * @param User $user
*
* @codeCoverageIgnore
*/ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
@ -104,6 +106,7 @@ class BunqPrerequisites implements PrerequisitesInterface
* @param array $data * @param array $data
* *
* @return MessageBag * @return MessageBag
*
*/ */
public function storePrerequisites(array $data): MessageBag public function storePrerequisites(array $data): MessageBag
{ {
@ -112,7 +115,6 @@ class BunqPrerequisites implements PrerequisitesInterface
Log::debug('Storing bunq API key'); Log::debug('Storing bunq API key');
app('preferences')->setForUser($this->user, 'bunq_api_key', $apiKey); app('preferences')->setForUser($this->user, 'bunq_api_key', $apiKey);
app('preferences')->setForUser($this->user, 'bunq_external_ip', $externalIP); app('preferences')->setForUser($this->user, 'bunq_external_ip', $externalIP);
$environment = $this->getBunqEnvironment(); $environment = $this->getBunqEnvironment();
$deviceDescription = 'Firefly III v' . config('firefly.version'); $deviceDescription = 'Firefly III v' . config('firefly.version');
$permittedIps = [$externalIP]; $permittedIps = [$externalIP];
@ -147,8 +149,10 @@ class BunqPrerequisites implements PrerequisitesInterface
} }
/** /**
* @codeCoverageIgnore * Get correct bunq environment.
*
* @return BunqEnumApiEnvironmentType * @return BunqEnumApiEnvironmentType
* @codeCoverageIgnore
*/ */
private function getBunqEnvironment(): BunqEnumApiEnvironmentType private function getBunqEnvironment(): BunqEnumApiEnvironmentType
{ {
@ -164,6 +168,8 @@ class BunqPrerequisites implements PrerequisitesInterface
} }
/** /**
* Check if we have API context.
*
* @return bool * @return bool
*/ */
private function hasApiContext(): bool private function hasApiContext(): bool
@ -180,6 +186,8 @@ class BunqPrerequisites implements PrerequisitesInterface
} }
/** /**
* Check if we have the API key.
*
* @return bool * @return bool
*/ */
private function hasApiKey(): bool private function hasApiKey(): bool
@ -196,6 +204,8 @@ class BunqPrerequisites implements PrerequisitesInterface
} }
/** /**
* Checks if we have an external IP.
*
* @return bool * @return bool
*/ */
private function hasExternalIP(): bool private function hasExternalIP(): bool

View File

@ -32,7 +32,7 @@ use Illuminate\Support\MessageBag;
*/ */
class FakePrerequisites implements PrerequisitesInterface class FakePrerequisites implements PrerequisitesInterface
{ {
/** @var User */ /** @var User The current user */
private $user; private $user;
/** /**
@ -87,6 +87,8 @@ class FakePrerequisites implements PrerequisitesInterface
} }
/** /**
* Store fake prerequisites.
*
* @param array $data * @param array $data
* *
* @return MessageBag * @return MessageBag
@ -107,6 +109,8 @@ class FakePrerequisites implements PrerequisitesInterface
} }
/** /**
* Check if we have an API key.
*
* @return bool * @return bool
*/ */
private function hasApiKey(): bool private function hasApiKey(): bool

View File

@ -26,9 +26,10 @@ use FireflyIII\User;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
/** /**
* @codeCoverageIgnore
* *
* This class contains all the routines necessary to import from a file. Hint: there are none. * This class contains all the routines necessary to import from a file. Hint: there are none.
*
* @codeCoverageIgnore
*/ */
class FilePrerequisites implements PrerequisitesInterface class FilePrerequisites implements PrerequisitesInterface
{ {

View File

@ -32,7 +32,7 @@ use Log;
*/ */
class SpectrePrerequisites implements PrerequisitesInterface class SpectrePrerequisites implements PrerequisitesInterface
{ {
/** @var User */ /** @var User The current user */
private $user; private $user;
/** /**
@ -156,6 +156,8 @@ class SpectrePrerequisites implements PrerequisitesInterface
} }
/** /**
* Check if we have the App ID.
*
* @return bool * @return bool
*/ */
private function hasAppId(): bool private function hasAppId(): bool
@ -172,6 +174,8 @@ class SpectrePrerequisites implements PrerequisitesInterface
} }
/** /**
* Check if we have the secret.
*
* @return bool * @return bool
*/ */
private function hasSecret(): bool private function hasSecret(): bool

View File

@ -35,10 +35,10 @@ use Log;
*/ */
class BunqRoutine implements RoutineInterface class BunqRoutine implements RoutineInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -63,7 +63,6 @@ class BunqRoutine implements RoutineInterface
$handler = app(StageNewHandler::class); $handler = app(StageNewHandler::class);
$handler->setImportJob($this->importJob); $handler->setImportJob($this->importJob);
$handler->run(); $handler->run();
// make user choose accounts to import from. // make user choose accounts to import from.
$this->repository->setStage($this->importJob, 'choose-accounts'); $this->repository->setStage($this->importJob, 'choose-accounts');
$this->repository->setStatus($this->importJob, 'need_job_config'); $this->repository->setStatus($this->importJob, 'need_job_config');
@ -91,6 +90,8 @@ class BunqRoutine implements RoutineInterface
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @return void * @return void

View File

@ -36,9 +36,9 @@ use Log;
*/ */
class FakeRoutine implements RoutineInterface class FakeRoutine implements RoutineInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -51,6 +51,9 @@ class FakeRoutine implements RoutineInterface
* *
* @return void * @return void
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public function run(): void public function run(): void
{ {
@ -93,6 +96,8 @@ class FakeRoutine implements RoutineInterface
} }
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
*/ */

View File

@ -33,9 +33,9 @@ use Log;
*/ */
class FileRoutine implements RoutineInterface class FileRoutine implements RoutineInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -66,6 +66,8 @@ class FileRoutine implements RoutineInterface
} }
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @return void * @return void

View File

@ -40,6 +40,8 @@ interface RoutineInterface
public function run(): void; public function run(): void;
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @return void * @return void

View File

@ -36,10 +36,10 @@ use Log;
class SpectreRoutine implements RoutineInterface class SpectreRoutine implements RoutineInterface
{ {
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** /**
@ -48,6 +48,9 @@ class SpectreRoutine implements RoutineInterface
* The final status of the routine must be "provider_finished". * The final status of the routine must be "provider_finished".
* *
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public function run(): void public function run(): void
{ {
@ -108,6 +111,8 @@ class SpectreRoutine implements RoutineInterface
} }
/** /**
* Set the import job.
*
* @param ImportJob $importJob * @param ImportJob $importJob
* *
* @return void * @return void

View File

@ -32,12 +32,14 @@ namespace FireflyIII\Import\Specifics;
*/ */
class AbnAmroDescription implements SpecificInterface class AbnAmroDescription implements SpecificInterface
{ {
/** @var array */ /** @var array The current row. */
public $row; public $row;
/** /**
* @codeCoverageIgnore * Description of this specific fix.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getDescription(): string public static function getDescription(): string
{ {
@ -45,8 +47,10 @@ class AbnAmroDescription implements SpecificInterface
} }
/** /**
* @codeCoverageIgnore * Name of specific fix.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getName(): string public static function getName(): string
{ {
@ -54,9 +58,13 @@ class AbnAmroDescription implements SpecificInterface
} }
/** /**
* Run the fix.
*
* @param array $row * @param array $row
* *
* @return array * @return array
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function run(array $row): array public function run(array $row): array
{ {
@ -123,6 +131,9 @@ class AbnAmroDescription implements SpecificInterface
* Parses the current description in SEPA format. * Parses the current description in SEPA format.
* *
* @return bool true if the description is SEPA format, false otherwise * @return bool true if the description is SEPA format, false otherwise
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
protected function parseSepaDescription(): bool protected function parseSepaDescription(): bool
{ {
@ -177,6 +188,9 @@ class AbnAmroDescription implements SpecificInterface
* Parses the current description in TRTP format. * Parses the current description in TRTP format.
* *
* @return bool true if the description is TRTP format, false otherwise * @return bool true if the description is TRTP format, false otherwise
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
protected function parseTRTPDescription(): bool protected function parseTRTPDescription(): bool
{ {

View File

@ -34,12 +34,14 @@ namespace FireflyIII\Import\Specifics;
*/ */
class IngDescription implements SpecificInterface class IngDescription implements SpecificInterface
{ {
/** @var array */ /** @var array The current row. */
public $row; public $row;
/** /**
* @codeCoverageIgnore * Description of the current specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getDescription(): string public static function getDescription(): string
{ {
@ -47,8 +49,10 @@ class IngDescription implements SpecificInterface
} }
/** /**
* @codeCoverageIgnore * Name of the current specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getName(): string public static function getName(): string
{ {
@ -56,9 +60,13 @@ class IngDescription implements SpecificInterface
} }
/** /**
* Run the specific code.
*
* @param array $row * @param array $row
* *
* @return array * @return array
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function run(array $row): array 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 private function copyDescriptionToOpposite(): void
{ {

View File

@ -28,8 +28,10 @@ namespace FireflyIII\Import\Specifics;
class PresidentsChoice implements SpecificInterface class PresidentsChoice implements SpecificInterface
{ {
/** /**
* @codeCoverageIgnore * Description of specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getDescription(): string public static function getDescription(): string
{ {
@ -37,8 +39,10 @@ class PresidentsChoice implements SpecificInterface
} }
/** /**
* @codeCoverageIgnore * Name of specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getName(): string public static function getName(): string
{ {
@ -46,6 +50,8 @@ class PresidentsChoice implements SpecificInterface
} }
/** /**
* Run this specific.
*
* @param array $row * @param array $row
* *
* @return array * @return array

View File

@ -26,12 +26,17 @@ use Log;
/** /**
* Class RabobankDescription. * Class RabobankDescription.
*
* @codeCoverageIgnore
* @deprecated
*/ */
class RabobankDescription implements SpecificInterface class RabobankDescription implements SpecificInterface
{ {
/** /**
* @codeCoverageIgnore * Description of this specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getDescription(): string public static function getDescription(): string
{ {
@ -39,8 +44,10 @@ class RabobankDescription implements SpecificInterface
} }
/** /**
* @codeCoverageIgnore * Name of this specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getName(): string public static function getName(): string
{ {
@ -48,9 +55,13 @@ class RabobankDescription implements SpecificInterface
} }
/** /**
* Run the specific.
*
* @param array $row * @param array $row
* *
* @return array * @return array
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/ */
public function run(array $row): array public function run(array $row): array
{ {

View File

@ -28,8 +28,10 @@ namespace FireflyIII\Import\Specifics;
class SnsDescription implements SpecificInterface class SnsDescription implements SpecificInterface
{ {
/** /**
* @codeCoverageIgnore * Get description of specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getDescription(): string public static function getDescription(): string
{ {
@ -37,8 +39,10 @@ class SnsDescription implements SpecificInterface
} }
/** /**
* @codeCoverageIgnore * Get name of specific.
*
* @return string * @return string
* @codeCoverageIgnore
*/ */
public static function getName(): string public static function getName(): string
{ {
@ -46,6 +50,8 @@ class SnsDescription implements SpecificInterface
} }
/** /**
* Run specific.
*
* @param array $row * @param array $row
* *
* @return array * @return array

View File

@ -28,16 +28,22 @@ namespace FireflyIII\Import\Specifics;
interface SpecificInterface interface SpecificInterface
{ {
/** /**
* Get description.
*
* @return string * @return string
*/ */
public static function getDescription(): string; public static function getDescription(): string;
/** /**
* Get name.
*
* @return string * @return string
*/ */
public static function getName(): string; public static function getName(): string;
/** /**
* Run specific.
*
* @param array $row * @param array $row
* *
* @return array * @return array

View File

@ -46,18 +46,20 @@ use Log;
* Creates new transactions based upon arrays. Will first check the array for duplicates. * Creates new transactions based upon arrays. Will first check the array for duplicates.
* *
* Class ImportArrayStorage * Class ImportArrayStorage
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/ */
class ImportArrayStorage class ImportArrayStorage
{ {
/** @var bool */ /** @var bool Check for transfers during import. */
private $checkForTransfers = false; private $checkForTransfers = false;
/** @var ImportJob */ /** @var ImportJob The import job */
private $importJob; private $importJob;
/** @var JournalRepositoryInterface */ /** @var JournalRepositoryInterface */
private $journalRepos; private $journalRepos;
/** @var ImportJobRepositoryInterface */ /** @var ImportJobRepositoryInterface Import job repository */
private $repository; private $repository;
/** @var Collection */ /** @var Collection The transfers. */
private $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. * 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 private function countTransfers(): void
{ {
@ -156,10 +160,10 @@ class ImportArrayStorage
} }
} }
if (0 === $count) { if (0 === $count) {
Log::debug('Count is zero.'); Log::debug('Count is zero, will not check for duplicate transfers.');
} }
if ($count > 0) { 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; $this->checkForTransfers = true;
// get users transfers. Needed for comparison. // get users transfers. Needed for comparison.
@ -169,6 +173,8 @@ class ImportArrayStorage
} }
/** /**
* Get hash of transaction.
*
* @param array $transaction * @param array $transaction
* *
* @throws FireflyException * @throws FireflyException
@ -339,6 +345,9 @@ class ImportArrayStorage
* *
* @return Collection * @return Collection
* @throws FireflyException * @throws FireflyException
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
private function storeArray(): Collection private function storeArray(): Collection
{ {
@ -431,6 +440,10 @@ class ImportArrayStorage
* @param $transaction * @param $transaction
* *
* @return bool * @return bool
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/ */
private function transferExists(array $transaction): bool private function transferExists(array $transaction): bool
{ {

View File

@ -167,8 +167,8 @@ class JournalRepository implements JournalRepositoryInterface
Log::debug(sprintf('JSON encoded hash is: %s', $jsonEncode)); Log::debug(sprintf('JSON encoded hash is: %s', $jsonEncode));
Log::debug(sprintf('Hash of hash is: %s', $hashOfHash)); Log::debug(sprintf('Hash of hash is: %s', $hashOfHash));
$result = TransactionJournalMeta $result = TransactionJournalMeta::withTrashed()
::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->where('hash', $hashOfHash) ->where('hash', $hashOfHash)
->where('name', 'importHashV2') ->where('name', 'importHashV2')
->first(['journal_meta.*']); ->first(['journal_meta.*']);