From 26fb03e6c85e5fc84c7271a847a2ddf2d24a554d Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 19 Jan 2016 09:11:15 +0100 Subject: [PATCH] Reformatted code according to scrutinizer-ci. --- app/Helpers/Csv/Converter/AmountComma.php | 6 +- .../Csv/Specifix/AbnAmroDescription.php | 87 ++++++++++--------- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/app/Helpers/Csv/Converter/AmountComma.php b/app/Helpers/Csv/Converter/AmountComma.php index 73f067f7aa..5fed5587b9 100644 --- a/app/Helpers/Csv/Converter/AmountComma.php +++ b/app/Helpers/Csv/Converter/AmountComma.php @@ -4,7 +4,7 @@ namespace FireflyIII\Helpers\Csv\Converter; /** * Class AmountComma - * + * * Parses the input as the amount with a comma as decimal separator * * @package FireflyIII\Helpers\Csv\Converter @@ -17,8 +17,8 @@ class AmountComma extends BasicConverter implements ConverterInterface */ public function convert() { - $value = str_replace(",", ".", $this->value ); - + $value = str_replace(',', '.', $this->value); + if (is_numeric($value)) { return floatval($value); } diff --git a/app/Helpers/Csv/Specifix/AbnAmroDescription.php b/app/Helpers/Csv/Specifix/AbnAmroDescription.php index 2b6b3c97d5..ecdc75b8bb 100644 --- a/app/Helpers/Csv/Specifix/AbnAmroDescription.php +++ b/app/Helpers/Csv/Specifix/AbnAmroDescription.php @@ -5,8 +5,8 @@ namespace FireflyIII\Helpers\Csv\Specifix; use Log; /** - * Parses the description from txt files for ABN AMRO bank accounts. - * + * Parses the description from txt files for ABN AMRO bank accounts. + * * Based on the logic as described in the following Gist: * https://gist.github.com/vDorst/68d555a6a90f62fec004 * @@ -31,10 +31,10 @@ class AbnAmroDescription // If the description could not be parsed, specify an unknown opposing // account, as an opposing account is required - if( !$parsed ) { - $this->data[ "opposing-account-name" ] = trans('firefly.unknown'); + if (!$parsed) { + $this->data['opposing-account-name'] = trans('firefly.unknown'); } - + return $this->data; } @@ -53,7 +53,7 @@ class AbnAmroDescription { $this->row = $row; } - + /** * Parses the current description in SEPA format * @return boolean true if the description is SEPA format, false otherwise @@ -61,18 +61,17 @@ class AbnAmroDescription protected function parseSepaDescription() { // See if the current description is formatted as a SEPA plain description - if( preg_match( "/^SEPA(.{28})/", $this->data[ "description" ], $matches ) ) { + if (preg_match('/^SEPA(.{28})/', $this->data['description'], $matches)) { Log::debug('AbnAmroSpecifix: Description is structured as SEPA plain description.'); - $type = trim($matches[1]); - + // SEPA plain descriptions contain several key-value pairs, split by a colon - preg_match_all( "/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s))/", $this->data[ "description" ], $matches, PREG_SET_ORDER ); - - foreach( $matches as $match ) { - $key = $match[1]; + preg_match_all('/([A-Za-z]+(?=:\s)):\s([A-Za-z 0-9._#-]+(?=\s))/', $this->data['description'], $matches, PREG_SET_ORDER); + + foreach ($matches as $match) { + $key = $match[1]; $value = trim($match[2]); - - switch( strtoupper($key) ) { + + switch (strtoupper($key)) { case 'OMSCHRIJVING': $this->data['description'] = $value; break; @@ -86,10 +85,10 @@ class AbnAmroDescription // Ignore the rest } } - + return true; } - + return false; } @@ -100,17 +99,18 @@ class AbnAmroDescription protected function parseTRTPDescription() { // See if the current description is formatted in TRTP format - if( preg_match_all( "!\/([A-Z]{3,4})\/([^/]*)!", $this->data[ "description" ], $matches, PREG_SET_ORDER ) ) { + if (preg_match_all('!\/([A-Z]{3,4})\/([^/]*)!', $this->data['description'], $matches, PREG_SET_ORDER)) { Log::debug('AbnAmroSpecifix: Description is structured as TRTP format.'); - - foreach( $matches as $match ) { - $key = $match[1]; + + foreach ($matches as $match) { + $key = $match[1]; $value = trim($match[2]); - - switch( strtoupper($key) ) { - case 'TRTP': - $type = $value; - break; + + switch (strtoupper($key)) { + // is not being used. +// case 'TRTP': +// $type = $value; +// break; case 'NAME': $this->data['opposing-account-name'] = $value; break; @@ -124,10 +124,10 @@ class AbnAmroDescription // Ignore the rest } } - + return true; } - + return false; } @@ -138,35 +138,36 @@ class AbnAmroDescription protected function parseGEABEADescription() { // See if the current description is formatted in GEA/BEA format - if( preg_match( "/([BG]EA) +(NR:[a-zA-Z:0-9]+) +([0-9.\/]+) +([^,]*)/", $this->data[ "description" ], $matches ) ) { + if (preg_match('/([BG]EA) +(NR:[a-zA-Z:0-9]+) +([0-9.\/]+) +([^,]*)/', $this->data['description'], $matches)) { Log::debug('AbnAmroSpecifix: Description is structured as GEA or BEA format.'); - - $this->data[ "opposing-account-name" ] = $matches[4]; - $this->data[ "description" ] = $matches[4]; - + + // description and opposing account will be the same. + $this->data['opposing-account-name'] = $matches[4]; + $this->data['description'] = $matches[4]; + return true; } - + return false; } - + /** * Parses the current description with costs from ABN AMRO itself - * @return boolean true if the description is GEA/BEAformat, false otherwise + * @return boolean true if the description is GEA/BEA-format, false otherwise */ protected function parseABNAMRODescription() { // See if the current description is formatted in ABN AMRO format - if( preg_match( "/ABN AMRO.{24} (.*)/", $this->data[ "description" ], $matches ) ) { + if (preg_match('/ABN AMRO.{24} (.*)/', $this->data['description'], $matches)) { Log::debug('AbnAmroSpecifix: Description is structured as costs from ABN AMRO itself.'); - - $this->data[ "opposing-account-name" ] = "ABN AMRO"; - $this->data[ "description" ] = $matches[1]; - + + $this->data['opposing-account-name'] = "ABN AMRO"; + $this->data['description'] = $matches[1]; + return true; } - + return false; } - + }