Skip to content

Commit

Permalink
Merge pull request #16 from fruitl00p/version_bump
Browse files Browse the repository at this point in the history
Version bump
  • Loading branch information
fruitl00p committed Jul 20, 2015
2 parents 940f922 + b61e91f commit aa1ac13
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 114 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ cache:
- $HOME/.composer/cache

php:
- 5.4
- 5.5
- 5.6
- 7
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{ "name": "Robin Speekenbrink", "email": "[email protected]" }
],
"require": {
"php": ">=5.4"
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "4.4.*",
Expand Down
2 changes: 1 addition & 1 deletion src/Banking/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Statement implements \JsonSerializable
{
private $bank = '';
private $account = '';
private $transactions = array();
private $transactions = [];
private $startPrice = 0.0;
private $endPrice = 0.0;
private $timestamp = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Banking.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Banking
*/
public function parse($string)
{
return array();
return [];
}
}
13 changes: 10 additions & 3 deletions src/Parser/Banking/Mt940.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@ class Mt940 extends Banking
* Parse the given string into an array of Banking\Statement objects
*
* @param string $string
* @param Banking\Mt940\Engine $engine
*
* @return \Kingsquare\Banking\Statement[]
*/
public function parse($string)
public function parse($string, Banking\Mt940\Engine $engine = null)
{
if (!empty($string)) {
// load engine
$this->engine = Banking\Mt940\Engine::__getInstance($string);
if ($engine === null) {
$engine = Banking\Mt940\Engine::__getInstance($string);
}

$this->engine = $engine;

if ($this->engine instanceof Banking\Mt940\Engine) {
// parse using the engine
$this->engine->loadString($string);
return $this->engine->parse();
}
}

return array();
return [];
}
}
36 changes: 18 additions & 18 deletions src/Parser/Banking/Mt940/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function loadString($string)
*/
public function parse()
{
$results = array();
$results = [];
foreach ($this->parseStatementData() as $this->currentStatementData) {
$statement = new Statement();
if ($this->debug) {
Expand Down Expand Up @@ -145,10 +145,10 @@ protected function parseStatementData()
*/
protected function parseTransactionData()
{
$results = array();
$results = [];
preg_match_all('/^:61:(.*?)(?=^:61:|^-X{,3}$|\Z)/sm', $this->getCurrentStatementData(), $results);

return ((!empty($results[0])) ? $results[0] : array());
return ((!empty($results[0])) ? $results[0] : []);
}

/**
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function parseStatementBank()
*/
protected function parseStatementAccount()
{
$results = array();
$results = [];
if (preg_match('/:25:([\d\.]+)*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -218,7 +218,7 @@ protected function parseStatementAccount()
*/
protected function parseStatementStartPrice()
{
$results = array();
$results = [];
if (preg_match('/:60F:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -234,7 +234,7 @@ protected function parseStatementStartPrice()
*/
protected function parseStatementEndPrice()
{
$results = array();
$results = [];
if (preg_match('/:62F:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -250,7 +250,7 @@ protected function parseStatementEndPrice()
*/
protected function parseStatementTimestamp()
{
$results = array();
$results = [];
if (preg_match('/:60F:[C|D](\d{6})*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -266,7 +266,7 @@ protected function parseStatementTimestamp()
*/
protected function parseStatementNumber()
{
$results = array();
$results = [];
if (preg_match('/:28C?:(.*)/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -283,7 +283,7 @@ protected function parseStatementNumber()
*/
protected function parseTransactionAccount()
{
$results = array();
$results = [];
if (preg_match('/^:86: ?([\d\.]+)\s/im', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -299,7 +299,7 @@ protected function parseTransactionAccount()
*/
protected function parseTransactionAccountName()
{
$results = array();
$results = [];
if (preg_match('/:86: ?[\d\.]+ (.+)/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -315,7 +315,7 @@ protected function parseTransactionAccountName()
*/
protected function parseTransactionPrice()
{
$results = array();
$results = [];
if (preg_match('/^:61:.*[CD]([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -331,7 +331,7 @@ protected function parseTransactionPrice()
*/
protected function parseTransactionDebitCredit()
{
$results = array();
$results = [];
if (preg_match('/^:61:\d+([CD])\d+/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -347,7 +347,7 @@ protected function parseTransactionDebitCredit()
*/
protected function parseTransactionDescription()
{
$results = array();
$results = [];
if (preg_match_all('/[\n]:86:(.*?)(?=\n(:6(1|2))|$)/s', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -363,7 +363,7 @@ protected function parseTransactionDescription()
*/
protected function parseTransactionEntryTimestamp()
{
$results = array();
$results = [];
if (preg_match('/^:61:(\d{6})/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -379,7 +379,7 @@ protected function parseTransactionEntryTimestamp()
*/
protected function parseTransactionValueTimestamp()
{
$results = array();
$results = [];
if (preg_match('/^:61:(\d{6})/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -395,7 +395,7 @@ protected function parseTransactionValueTimestamp()
*/
protected function parseTransactionCode()
{
$results = array();
$results = [];
if (preg_match('/^:61:.*?N(.{3}).*/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -412,11 +412,11 @@ protected function parseTransactionCode()
*/
protected function sanitizeAccount($string)
{
static $crudeReplacements = array(
static $crudeReplacements = [
'.' => '',
' ' => '',
'GIRO' => 'P',
);
];

// crude IBAN to 'old' converter
if (Mt940::$removeIBAN
Expand Down
6 changes: 3 additions & 3 deletions src/Parser/Banking/Mt940/Engine/Abn.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function parseTransactionAccount()
$results = parent::parseTransactionAccount();

if (empty($results)) {
$giroMatch = $ibanMatch = array();
$giroMatch = $ibanMatch = [];
if (preg_match('/^:86:GIRO(.{9})/im', $this->getCurrentTransactionData(), $giroMatch)
&& !empty($giroMatch[1])
) {
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function parseTransactionAccountName()
return $results;
}

$results = array();
$results = [];
if (preg_match('/:86:(GIRO|BGC\.)\s+[\d]+ (.+)/', $this->getCurrentTransactionData(), $results)
&& !empty($results[2])
) {
Expand All @@ -82,7 +82,7 @@ protected function parseTransactionAccountName()
*/
protected function parseTransactionEntryTimestamp()
{
$results = array();
$results = [];
if (preg_match('/^:61:\d{6}(\d{4})[C|D]/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand Down
8 changes: 4 additions & 4 deletions src/Parser/Banking/Mt940/Engine/Rabo.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function parseStatementBank()
*/
protected function parseTransactionAccount()
{
$results = array();
$results = [];
// SEPA MT940 Structured
if (preg_match('/^:61:.*\n(.*?)(\n|\:8)/im', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
Expand All @@ -47,7 +47,7 @@ protected function parseTransactionAccount()
*/
protected function parseTransactionAccountName()
{
$results = array();
$results = [];
// SEPA MT940 Structured
if (preg_match('#/NAME/(.*?)/(REMI|ADDR)/#ms', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
Expand All @@ -74,7 +74,7 @@ protected function parseTransactionAccountName()
*/
protected function parseTransactionEntryTimestamp()
{
$results = array();
$results = [];
if (preg_match('/^:60F:[C|D]([\d]{6})/m', $this->getCurrentStatementData(), $results) && !empty($results[1])) {
return $this->sanitizeTimestamp($results[1], 'ymd');
}
Expand All @@ -88,7 +88,7 @@ protected function parseTransactionEntryTimestamp()
*/
protected function parseTransactionValueTimestamp()
{
$results = array();
$results = [];
if (preg_match('/^:61:([\d]{6})[C|D]/', $this->getCurrentTransactionData(), $results) && !empty($results[1])) {
return $this->sanitizeTimestamp($results[1], 'ymd');
}
Expand Down
10 changes: 5 additions & 5 deletions src/Parser/Banking/Mt940/Engine/Spk.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function parseStatementBank()
*/
protected function parseStatementStartPrice()
{
$results = array();
$results = [];
if (preg_match('/:60[FM]:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -45,7 +45,7 @@ protected function parseStatementStartPrice()
*/
protected function parseStatementTimestamp()
{
$results = array();
$results = [];
if (preg_match('/:60[FM]:[C|D](\d{6})*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -61,7 +61,7 @@ protected function parseStatementTimestamp()
*/
protected function parseStatementEndPrice()
{
$results = array();
$results = [];
if (preg_match('/:62[FM]:.*EUR([\d,\.]+)*/', $this->getCurrentStatementData(), $results)
&& !empty($results[1])
) {
Expand All @@ -77,7 +77,7 @@ protected function parseStatementEndPrice()
*/
protected function parseTransactionPrice()
{
$results = array();
$results = [];
if (preg_match('/^:61:.*[CD].?([\d,\.]+)N/i', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand All @@ -93,7 +93,7 @@ protected function parseTransactionPrice()
*/
protected function parseTransactionDebitCredit()
{
$results = array();
$results = [];
if (preg_match('/^:61:\d+R?([CD]).?\d+/', $this->getCurrentTransactionData(), $results)
&& !empty($results[1])
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Banking/Mt940/Engine/Triodos.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function parseStatementBank()
*/
protected function parseStatementAccount()
{
$results = array();
$results = [];
if (preg_match('#:25:TRIODOSBANK/([\d\.]+)#', $this->getCurrentStatementData(), $results) && !empty($results[1])
) {
return $this->sanitizeAccount($results[1]);
Expand Down
Loading

0 comments on commit aa1ac13

Please sign in to comment.