From b04cdd996a32af291e30134d2bb1f54f586420a4 Mon Sep 17 00:00:00 2001 From: Robin Speekenbrink Date: Mon, 18 Mar 2019 15:48:56 +0100 Subject: [PATCH] some code reformatting / inlined a method --- src/Parser/Banking/Mt940/Engine/Hsbc.php | 16 ++++++------ src/Parser/Banking/Mt940/Engine/Rabo.php | 2 +- src/Parser/Banking/Mt940/Engine/Sns.php | 31 +++++++++++++++++------- src/Parser/Banking/Mt940/Engine/Spk.php | 8 +++--- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/Parser/Banking/Mt940/Engine/Hsbc.php b/src/Parser/Banking/Mt940/Engine/Hsbc.php index e532770..5ea30af 100644 --- a/src/Parser/Banking/Mt940/Engine/Hsbc.php +++ b/src/Parser/Banking/Mt940/Engine/Hsbc.php @@ -95,7 +95,7 @@ protected function parseStatementAccount() { $results = []; if (preg_match('/:25:([0-9X]+)*/', $this->getCurrentStatementData(), $results) - && ! empty($results[1]) + && !empty($results[1]) ) { return $this->sanitizeAccount($results[1]); } @@ -149,21 +149,21 @@ protected function parseTransactionAccountName() // SEPA MT940 Structured if (preg_match('#/NAME/(.+?)\n?/(REMI|ADDR|ISDT|CSID)/#ms', $this->getCurrentTransactionData(), $results)) { $accountName = trim($results[1]); - if ( ! empty($accountName)) { + if (!empty($accountName)) { return $this->sanitizeAccountName($accountName); } } if (preg_match('/^:61:.*? (.+)/m', $this->getCurrentTransactionData(), $results)) { $accountName = trim($results[1]); - if ( ! empty($accountName)) { + if (!empty($accountName)) { return $this->sanitizeAccountName($accountName); } } if (preg_match('/(.*) Betaalautomaat/', $this->parseTransactionDescription(), $results)) { $accountName = trim($results[1]); - if ( ! empty($accountName)) { + if (!empty($accountName)) { return $this->sanitizeAccountName($accountName); } } @@ -224,12 +224,12 @@ protected function sanitizeDescription($string) { $description = parent::sanitizeDescription($string); if (strpos($description, '/REMI/') !== false - && preg_match('#/REMI/(.*?)(/((PURP|ISDT|CSID|RTRN)/)|$)#s', $description, $results) && ! empty($results[1]) + && preg_match('#/REMI/(.*?)(/((PURP|ISDT|CSID|RTRN)/)|$)#s', $description, $results) && !empty($results[1]) ) { return $results[1]; } if (strpos($description, '/EREF/') !== false - && preg_match('#/EREF/(.*?)/(ORDP)/#s', $description, $results) && ! empty($results[1]) + && preg_match('#/EREF/(.*?)/(ORDP)/#s', $description, $results) && !empty($results[1]) ) { return $results[1]; } @@ -246,9 +246,9 @@ protected function sanitizeDescription($string) */ protected function sanitizeDebitCredit($string) { - $debitOrCredit = strtoupper(substr((string) $string, -1, 1)); + $debitOrCredit = strtoupper(substr((string)$string, -1, 1)); if ($debitOrCredit !== Transaction::DEBIT && $debitOrCredit !== Transaction::CREDIT) { - trigger_error('wrong value for debit/credit ('.$string.')', E_USER_ERROR); + trigger_error('wrong value for debit/credit (' . $string . ')', E_USER_ERROR); $debitOrCredit = ''; } diff --git a/src/Parser/Banking/Mt940/Engine/Rabo.php b/src/Parser/Banking/Mt940/Engine/Rabo.php index 1686714..7e4efba 100644 --- a/src/Parser/Banking/Mt940/Engine/Rabo.php +++ b/src/Parser/Banking/Mt940/Engine/Rabo.php @@ -141,7 +141,7 @@ protected function sanitizeDescription($string) } if (strpos($description, '/PREF/') !== false - && preg_match('#/PREF/(.*)/?#s', $description, $results) && !empty($results[1]) + && preg_match('#/PREF/(.*)/?#s', $description, $results) && !empty($results[1]) ) { return $results[1]; } diff --git a/src/Parser/Banking/Mt940/Engine/Sns.php b/src/Parser/Banking/Mt940/Engine/Sns.php index bc3cd75..ae21d40 100644 --- a/src/Parser/Banking/Mt940/Engine/Sns.php +++ b/src/Parser/Banking/Mt940/Engine/Sns.php @@ -1,9 +1,13 @@ getCurrentTransactionData(), $results) && !empty($results[1]) ) { - $this->filterMetaDataFromDescription($results); + // filter out meta data + $lines = explode("\r\n", $results[1][0]); + unset($lines[0], $lines[1]); + $results[1][0] = implode("\r\n", $lines); return $this->sanitizeDescription(implode(PHP_EOL, $results[1])); } @@ -62,12 +83,4 @@ protected function parseTransactionDescription() return ''; } - private function filterMetaDataFromDescription(&$results) - { - $lines = explode("\r\n", $results[1][0]); - unset($lines[0]); - unset($lines[1]); - $results[1][0] = implode("\r\n", $lines); - } - } diff --git a/src/Parser/Banking/Mt940/Engine/Spk.php b/src/Parser/Banking/Mt940/Engine/Spk.php index 17301a5..9d95b38 100644 --- a/src/Parser/Banking/Mt940/Engine/Spk.php +++ b/src/Parser/Banking/Mt940/Engine/Spk.php @@ -29,7 +29,7 @@ protected function parseStatementBank() */ protected function parseStatementStartPrice() { - return parent::parseStatementPrice('60[FM]'); + return $this->parseStatementPrice('60[FM]'); } /** @@ -39,7 +39,7 @@ protected function parseStatementStartPrice() */ protected function parseStatementStartTimestamp() { - return parent::parseTimestampFromStatement('60[FM]'); + return $this->parseTimestampFromStatement('60[FM]'); } /** @@ -49,7 +49,7 @@ protected function parseStatementStartTimestamp() */ protected function parseStatementEndTimestamp() { - return parent::parseTimestampFromStatement('60[FM]'); + return $this->parseTimestampFromStatement('60[FM]'); } /** @@ -59,7 +59,7 @@ protected function parseStatementEndTimestamp() */ protected function parseStatementEndPrice() { - return parent::parseStatementPrice('62[FM]'); + return $this->parseStatementPrice('62[FM]'); } /**