-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,443 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2023 Dominic Richter - chargecloud Gmbh (https://www.chargecloud.de) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Jejik\MT940 library | ||
* | ||
* Copyright (c) 2023 Sennur Tas - chargecloud GmbH | ||
* Licensed under the MIT license | ||
* | ||
* For the full copyright and license information, please see the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Jejik\MT940\Parser; | ||
|
||
/** | ||
* Class BayerischeLandesbank | ||
* @package Jejik\MT940\Parser | ||
*/ | ||
class BayerischeLandesbank extends GermanBank | ||
{ | ||
/** | ||
* @return string[] | ||
*/ | ||
public function getAllowedBLZ(): array | ||
{ | ||
return ['70050000']; | ||
} | ||
|
||
/** | ||
* @param string $text | ||
* @return bool | ||
*/ | ||
public function accept(string $text): bool | ||
{ | ||
$allowedUniqueIdentifiers = [ | ||
':20:21766916', | ||
]; | ||
|
||
$mt940Identifier = substr($text, 0, 12); | ||
if (in_array($mt940Identifier, $allowedUniqueIdentifiers)) { | ||
return true; | ||
} | ||
|
||
return $this->isBLZAllowed($text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Jejik\MT940 library | ||
* | ||
* Copyright (c) 2023 Sennur Tas - chargecloud GmbH | ||
* Licensed under the MIT license | ||
* | ||
* For the full copyright and license information, please see the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Jejik\MT940\Parser; | ||
|
||
/** | ||
* Parser for Banque Internationale a Luxembourg | ||
* | ||
* Class Bil | ||
* @package Jejik\MT940\Parser | ||
* | ||
*/ | ||
class Bil extends AbstractParser | ||
{ | ||
|
||
/** | ||
* @param string $text | ||
* @return bool | ||
*/ | ||
public function accept(string $text): bool | ||
{ | ||
if (empty($text)) { | ||
return false; | ||
} | ||
{ | ||
$allowedUniqueIdentifiers = [ | ||
':20:BILMT940', | ||
]; | ||
|
||
$mt940Identifier = substr($text, 0, 12); | ||
if (in_array($mt940Identifier, $allowedUniqueIdentifiers)) { | ||
return true; | ||
} | ||
|
||
return $this->isBLZAllowed($text); | ||
} | ||
} | ||
|
||
/** | ||
* Get an array of allowed BLZ for this bank | ||
*/ | ||
public function getAllowedBLZ(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @param array $lines | ||
* @return string|null | ||
*/ | ||
protected function gvc(array $lines): ?string | ||
{ | ||
$gvcLine = $lines[1] ?? null; | ||
|
||
if ($gvcLine == null) { | ||
return null; | ||
} | ||
|
||
return substr($gvcLine, 0, 3); | ||
} | ||
|
||
/** | ||
* Parse txText for provided transaction lines | ||
*/ | ||
protected function txText(array $lines): ?string | ||
{ | ||
$txTextLine = isset($lines[1]) ? $lines[1] : null; | ||
|
||
if ($txTextLine === null) { | ||
return null; | ||
} | ||
|
||
/** @var string $txTextLine */ | ||
preg_match('#\?00([a-zA-Z0-9\-\s\.]+)#', $this->removeNewLinesFromLine($txTextLine), $match); | ||
|
||
if (!isset($match[1])) { | ||
return null; | ||
} | ||
|
||
return $match[1]; | ||
} | ||
|
||
/** | ||
* Remove all new lines and carriage returns from provided input line | ||
*/ | ||
private function removeNewLinesFromLine(string $stringLine): string | ||
{ | ||
return str_replace(["\n", "\r", "\r\n"], '', $stringLine); | ||
} | ||
|
||
/** Get raw data of subfields ?20 - ?29 | ||
* | ||
* @param array $lines | ||
* @return string|string[]|null | ||
*/ | ||
protected function rawSubfieldsData(array $lines) | ||
{ | ||
$subflieldline = isset($lines[1]) ? $lines[1] : null; | ||
|
||
$multiUseLine = $this->removeNewLinesFromLine($subflieldline); | ||
preg_match('#(\?2[0-9][^?]+)+#', $multiUseLine, $match); | ||
|
||
if (!isset($match[0])) { | ||
return null; | ||
} | ||
|
||
return preg_replace('#(\?2[0-9])#', '', $match[0]); | ||
} | ||
|
||
/** | ||
* Parse code for provided transaction lines | ||
*/ | ||
protected function code(array $lines): ?string | ||
{ | ||
$codeLine = isset($lines[0]) ? $lines[0] : null; | ||
|
||
if ($codeLine == null) { | ||
return null; | ||
} | ||
preg_match('#(\d{6})(\d{4})?(R?(?:C|D)R?)([0-9,]{1,15})N([a-zA-Z0-9]+)#', $codeLine, $match); | ||
|
||
if (!isset($match[5])) { | ||
return null; | ||
} | ||
return substr($match[5], 0, 3); | ||
} | ||
|
||
/** | ||
* Parse ref for provided transaction lines | ||
*/ | ||
protected function ref(array $lines): ?string | ||
{ | ||
|
||
$refLine = isset($lines[0]) ? $lines[0] : null; | ||
|
||
if ($refLine == null) { | ||
return null; | ||
} | ||
preg_match('#(?:\d{10})?(R?(?:C|D)R?)(?:[\d,]{1,15})N(.){3}([A-Za-z0-9\.]+)#', $refLine, $match); | ||
if (!isset($match[3])) { | ||
return null; | ||
} | ||
|
||
return $match[3]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.