Last code optimization before release.

This commit is contained in:
James Cole
2018-07-28 10:45:16 +02:00
parent d35470a79e
commit 0c7b652a70
42 changed files with 217 additions and 301 deletions

View File

@@ -271,6 +271,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
*
* @return array
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array
{

View File

@@ -58,6 +58,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
* @param array $config
*
* @return MessageBag
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function configurationComplete(array $config): MessageBag
{

View File

@@ -110,6 +110,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
*
* @return array
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getNextData(): array
{

View File

@@ -128,6 +128,7 @@ class ImportTransaction
* @param ColumnValue $columnValue
*
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function addColumnValue(ColumnValue $columnValue): void
{

View File

@@ -48,6 +48,7 @@ class AssetAccountMapper
* @param array $data
*
* @return Account
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function map(?int $accountId, array $data): Account
{

View File

@@ -81,6 +81,7 @@ class MappedValuesValidator
*
* @return array
* @throws FireflyException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function validate(array $mappings): array
{

View File

@@ -135,44 +135,32 @@ class MappingConverger
return $role;
}
switch ($role) {
default:
throw new FireflyException(sprintf('Cannot indicate new role for mapped role "%s"', $role)); // @codeCoverageIgnore
case 'account-id':
case 'account-name':
case 'account-iban':
case 'account-number':
$newRole = 'account-id';
break;
case 'bill-id':
case 'bill-name':
$newRole = 'bill-id';
break;
case 'budget-id':
case 'budget-name':
$newRole = 'budget-id';
break;
case 'currency-id':
case 'currency-name':
case 'currency-code':
case 'currency-symbol':
$newRole = 'currency-id';
break;
case 'category-id':
case 'category-name':
$newRole = 'category-id';
break;
case 'foreign-currency-id':
case 'foreign-currency-code':
$newRole = 'foreign-currency-id';
break;
case 'opposing-id':
case 'opposing-name':
case 'opposing-iban':
case 'opposing-number':
$newRole = 'opposing-id';
break;
$roleMapping = [
'account-id' => 'account-id',
'account-name' => 'account-id',
'account-iban' => 'account-id',
'account-number' => 'account-id',
'bill-id' => 'bill-id',
'bill-name' => 'bill-id',
'budget-id' => 'budget-id',
'budget-name' => 'budget-id',
'currency-id' => 'currency-id',
'currency-name' => 'currency-id',
'currency-code' => 'currency-id',
'currency-symbol' => 'currency-id',
'category-id' => 'category-id',
'category-name' => 'category-id',
'foreign-currency-id' => 'foreign-currency-id',
'foreign-currency-code' => 'foreign-currency-id',
'opposing-id' => 'opposing-id',
'opposing-name' => 'opposing-id',
'opposing-iban' => 'opposing-id',
'opposing-number' => 'opposing-id',
];
if (!isset($roleMapping[$role])) {
throw new FireflyException(sprintf('Cannot indicate new role for mapped role "%s"', $role)); // @codeCoverageIgnore
}
$newRole = $roleMapping[$role];
Log::debug(sprintf('Role was "%s", but because of mapping (mapped to #%d), role becomes "%s"', $role, $mapped, $newRole));
// also store the $mapped values in a "mappedValues" array.

View File

@@ -45,6 +45,7 @@ class OpposingAccountMapper
* @param array $data
*
* @return Account
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function map(?int $accountId, string $amount, array $data): Account
{

View File

@@ -107,6 +107,7 @@ class StageImportDataHandler
* @param LocalAccount $originalSource
*
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array
{