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
48 changed files with 182 additions and 131 deletions

View File

@@ -26,6 +26,7 @@ use Log;
/**
* Class Amount.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -29,6 +29,7 @@ use Illuminate\Support\MessageBag;
/**
* Class FakeJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -37,6 +37,7 @@ use Illuminate\Support\MessageBag;
/**
* Class FileJobConfiguration
*
* @deprecated
* @codeCoverageIgnore
*/
@@ -63,8 +64,8 @@ class FileJobConfiguration implements JobConfigurationInterface
*
* @param array $data
*
* @return MessageBag
* @throws FireflyException
* @return 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.
*
* @throws FireflyException
* @return string
*
*@throws FireflyException
*/
public function getNextView(): string
{
@@ -130,9 +131,9 @@ class FileJobConfiguration implements JobConfigurationInterface
/**
* Get the configuration handler for this specific stage.
*
* @return FileConfigurationInterface
* @throws FireflyException
*
* @return FileConfigurationInterface
*/
private function getConfigurationObject(): FileConfigurationInterface
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class AssetAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -27,6 +27,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
/**
* Class Bills.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -27,6 +27,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
/**
* Class Budgets.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -27,6 +27,7 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
/**
* Class Categories.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

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

View File

@@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccounts.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -28,6 +28,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
/**
* Class OpposingAccounts.
*
* @deprecated
* @codeCoverageIgnore
*

View File

@@ -27,6 +27,7 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
/**
* Class Tags.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -26,6 +26,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
/**
* Class TransactionCurrencies.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

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

View File

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

View File

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

View File

@@ -33,6 +33,7 @@ use Log;
/**
* This class contains all the routines necessary to connect to Bunq.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -25,11 +25,13 @@ namespace FireflyIII\Import\Prerequisites;
use FireflyIII\User;
use Illuminate\Support\MessageBag;
use Log;
use function request;
/**
* This class contains all the routines necessary for the fake import provider.
*
* Class FakePrerequisites
*
* @deprecated
* @codeCoverageIgnore
*/
@@ -70,9 +72,9 @@ class FakePrerequisites implements PrerequisitesInterface
if ($this->hasApiKey()) {
$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) {
$apiKey = \request()->old('api_key'); // @codeCoverageIgnore
$apiKey = request()->old('api_key'); // @codeCoverageIgnore
}
return ['api_key' => $apiKey];

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)));
}
}
/**
* Returns view name that allows user to fill in prerequisites.
*

View File

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

View File

@@ -29,6 +29,7 @@ use Log;
/**
* This class contains all the routines necessary to connect to Spectre.
*
* @deprecated
* @codeCoverageIgnore
*/

View File

@@ -29,6 +29,7 @@ use Log;
/**
* Class YnabPrerequisites
*
* @deprecated
* @codeCoverageIgnore
*/

View File

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

View File

@@ -33,6 +33,7 @@ use Log;
/**
* Class FakeRoutine
*
* @deprecated
* @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.
* "final": will do some logging, sleep for 10 seconds and then finish. Generates 5 random transactions.
*
* @return void
* @throws FireflyException
*
* @return void
*/
public function run(): void
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Import\Specifics;
/**
* Class Belfius.
*
* @deprecated
* @codeCoverageIgnore
*
@@ -56,19 +57,6 @@ class Belfius implements SpecificInterface
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
* transaction is imported for another bank account.
@@ -92,4 +80,17 @@ class Belfius implements SpecificInterface
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.
*
* @deprecated
* @codeCoverageIgnore
*
@@ -55,16 +56,37 @@ class IngBelgium implements SpecificInterface
}
/**
* Run the specific code.
*
* @param array $row
*
* @return array
* Gets the description from the transaction details and makes sure structured descriptions are in the
* "+++090/9337/55493+++" format.
*
* @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 opposing account's IBAN from the transaction details.
*
* @return string the opposing account's IBAN
*/
protected static function opposingAccountIban(string $transactionDetails): string
{
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/');
}
/**
* Gets the opposing account name from the transaction details.
*
* @return string the opposing account name
*/
protected static function opposingAccountName(string $transactionDetails): string
{
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Van:\s*(.+?)(?=\s{2,})/');
}
/**
@@ -81,48 +103,17 @@ class IngBelgium implements SpecificInterface
$row[12] = IngBelgium::opposingAccountIban($transactionDetails);
$row[13] = IngBelgium::description($transactionDetails);
}
return $row;
}
/**
* Gets the opposing account name from the transaction details.
*
* @return string the opposing account name
*/
protected static function opposingAccountName(string $transactionDetails): string
{
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/Van:\s*(.+?)(?=\s{2,})/');
}
/**
* Gets the opposing account's IBAN from the transaction details.
*
* @return string the opposing account's IBAN
*/
protected static function opposingAccountIban(string $transactionDetails): string
{
return IngBelgium::parseInformationFromTransactionDetails($transactionDetails, '/IBAN:\s*(.+?)(?=\s+)/');
}
/**
* 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
{
preg_match('/^\*\*\*(\d{3}\/\d{4}\/\d{5})\*\*\*$/', $description, $matches);
if (isset($matches[1])) {
return '+++' . $matches[1] . '+++';
}
return $description;
}
@@ -137,4 +128,17 @@ class IngBelgium implements SpecificInterface
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.
*
* @deprecated
* @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]);
}
/**
* 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.
*/
@@ -131,23 +143,12 @@ class IngDescription implements SpecificInterface
$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.
*/
private function MoveSavingsAccount(): void
{
$matches = array();
$matches = [];
if ('' === (string) $this->row[3]) {
if (preg_match('/(Naar|Van) (.*rekening) ([0-9]+)/', $this->row[8], $matches)) {
$matches[3] = sprintf("%010d", $matches[3]);

View File

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

View File

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

View File

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

View File

@@ -32,17 +32,14 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\TransactionRules\Engine\RuleEngine;
use FireflyIII\TransactionRules\Processor;
use Illuminate\Database\QueryException;
use Illuminate\Support\Collection;
use Log;
@@ -51,6 +48,7 @@ use Log;
* Creates new transactions based on arrays.
*
* Class ImportArrayStorage
*
* @codeCoverageIgnore
* @deprecated
*
@@ -107,8 +105,8 @@ class ImportArrayStorage
* - Link to tag
* - Run rules (if set to)
*
* @return Collection
* @throws FireflyException
* @return Collection
*/
public function store(): Collection
{
@@ -475,9 +473,9 @@ class ImportArrayStorage
/**
* Store array as journals.
*
* @return Collection
* @throws FireflyException
*
* @return Collection
*/
private function storeGroupArray(): Collection
{