AbcAeffchen\SepaUtilities\SepaUtilities
Useful methods to validate an sanitize input used in SEPA files
Synopsis
- // constants
- const SEPA_PAIN_001_002_03 = 100203;
- const SEPA_PAIN_001_003_03 = 100303;
- const SEPA_PAIN_001_001_03 = 100103;
- const SEPA_PAIN_001_001_03_GBIC = 1001031;
- const SEPA_PAIN_008_002_02 = 800202;
- const SEPA_PAIN_008_003_02 = 800302;
- const SEPA_PAIN_008_001_02 = 800102;
- const SEPA_PAIN_008_001_02_GBIC = 8001021;
- const HTML_PATTERN_IBAN = '([a-zA-Z]\s*){2}([0-9]\s?){2}\s*([a-zA-Z0-9]\s*){1,30}';
- const HTML_PATTERN_BIC = '([a-zA-Z]\s*){6}[a-zA-Z2-9]\s*[a-nA-Np-zP-Z0-9]\s*(([A-Z0-9]\s*){3}){0,1}';
- const PATTERN_IBAN = '[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}';
- const PATTERN_BIC = '[A-Z]{6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3}){0,1}';
- const PATTERN_CREDITOR_IDENTIFIER = '[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){3,3}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){1,28}';
- const PATTERN_SHORT_TEXT = '[a-zA-Z0-9/\-?:().,\'+\s]{0,70}';
- const PATTERN_LONG_TEXT = '[a-zA-Z0-9/\-?:().,\'+\s]{0,140}';
- const PATTERN_RESTRICTED_IDENTIFICATION_SEPA1 = '([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\'|\s]){1,35}';
- const PATTERN_RESTRICTED_IDENTIFICATION_SEPA2 = '([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){1,35}';
- const PATTERN_MANDATE_ID = self::PATTERN_RESTRICTED_IDENTIFICATION_SEPA2;
- const FLAG_ALT_REPLACEMENT_GERMAN = 1;
- const FLAG_NO_REPLACEMENT_GERMAN = 32768;
- const SEQUENCE_TYPE_FIRST = 'FRST';
- const SEQUENCE_TYPE_RECURRING = 'RCUR';
- const SEQUENCE_TYPE_ONCE = 'OOFF';
- const SEQUENCE_TYPE_FINAL = 'FNAL';
- const LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT = 'CORE';
- const LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT_D_1 = 'COR1';
- const LOCAL_INSTRUMENT_BUSINESS_2_BUSINESS = 'B2B';
- const BIC_REQUIRED_THRESHOLD = 20160131;
- // members
- private static array $ibanPatterns = ;
- private static array $alphabet = ;
- private static array $alphabetValues = ;
- private static array $mod97Values = ;
- private static array $specialChars = ;
- private static array $specialCharsReplacement = ;
- private static array $bicIbanCountryCodeExceptions = ;
- // methods
- public static void checkCreditorIdentifier()
- public static string|false checkIBAN()
- private static void iso7064Mod97m10ChecksumCheck()
- public static string|false checkBIC()
- public static bool isNationalTransaction()
- public static bool crossCheckIbanBic()
- private static void checkDateFormat()
- public static string|false sanitizeDateFormat()
- public static string|false checkCreateDateTime()
- public static string|false getDate()
- public static string|false getDateWithOffset()
- public static string getDateWithMinOffsetFromToday()
- private static bool dateIsTargetDay()
- private static mixed|false getValFromMultiDimInput()
- public static false|mixed check()
- public static mixed|false checkInput()
- public static mixed|false sanitizeInput()
- public static mixed|false checkAndSanitize()
- public static false|mixed checkAndSanitizeInput()
- public static true|string checkAndSanitizeAll()
- public static void sanitizeShortText()
- public static void sanitizeLongText()
- public static mixed|false sanitize()
- public static void checkRequiredCollectionKeys()
- public static void checkRequiredPaymentKeys()
- public static bool containsAllKeys()
- public static bool containsNotAnyKey()
- private static string|false checkActiveOrHistoricCurrencyCode()
- private static string|false checkBoolean()
- private static string|bool checkRestrictedIdentificationSEPA1()
- private static string|bool checkRestrictedIdentificationSEPA2()
- private static string|bool checkRestrictedPersonIdentifierSEPA()
- private static bool checkLength()
- public static string sanitizeLength()
- public static string replaceSpecialChars()
- private static void checkCharset()
- private static float|false checkAmountFormat()
- private static string|false checkSeqType()
- private static bool|string checkLocalInstrument()
- private static void checkCategoryPurpose()
- private static void checkPurpose()
- private static void changeArrayValuesByAssocArray()
- private static void changeArrayValuesToKeys()
Tasks
Line | Task |
---|---|
216 | does this break the ci? |
Constants
Name | Value |
---|---|
SEPA_PAIN_001_002_03 | 100203 |
SEPA_PAIN_001_003_03 | 100303 |
SEPA_PAIN_001_001_03 | 100103 |
SEPA_PAIN_001_001_03_GBIC | 1001031 |
SEPA_PAIN_008_002_02 | 800202 |
SEPA_PAIN_008_003_02 | 800302 |
SEPA_PAIN_008_001_02 | 800102 |
SEPA_PAIN_008_001_02_GBIC | 8001021 |
HTML_PATTERN_IBAN | '([a-zA-Z]\s*){2}([0-9]\s?){2}\s*([a-zA-Z0-9]\s*){1,30}' |
HTML_PATTERN_BIC | '([a-zA-Z]\s*){6}[a-zA-Z2-9]\s*[a-nA-Np-zP-Z0-9]\s*(([A-Z0-9]\s*){3}){0,1}' |
PATTERN_IBAN | '[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}' |
PATTERN_BIC | '[A-Z]{6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3}){0,1}' |
PATTERN_CREDITOR_IDENTIFIER | '[a-zA-Z]{2,2}[0-9]{2,2}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){3,3}([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){1,28}' |
PATTERN_SHORT_TEXT | '[a-zA-Z0-9/\-?:().,\'+\s]{0,70}' |
PATTERN_LONG_TEXT | '[a-zA-Z0-9/\-?:().,\'+\s]{0,140}' |
PATTERN_RESTRICTED_IDENTIFICATION_SEPA1 | '([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\'|\s]){1,35}' |
PATTERN_RESTRICTED_IDENTIFICATION_SEPA2 | '([A-Za-z0-9]|[\+|\?|/|\-|:|\(|\)|\.|,|\']){1,35}' |
PATTERN_MANDATE_ID | self::PATTERN_RESTRICTED_IDENTIFICATION_SEPA2 |
FLAG_ALT_REPLACEMENT_GERMAN | 1 |
FLAG_NO_REPLACEMENT_GERMAN | 32768 |
SEQUENCE_TYPE_FIRST | 'FRST' |
SEQUENCE_TYPE_RECURRING | 'RCUR' |
SEQUENCE_TYPE_ONCE | 'OOFF' |
SEQUENCE_TYPE_FINAL | 'FNAL' |
LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT | 'CORE' |
LOCAL_INSTRUMENT_CORE_DIRECT_DEBIT_D_1 | 'COR1' |
LOCAL_INSTRUMENT_BUSINESS_2_BUSINESS | 'B2B' |
BIC_REQUIRED_THRESHOLD | 20160131 |
Members
private
- $alphabet
- $alphabetValues
- $bicIbanCountryCodeExceptions
- $ibanPatterns
- $mod97Values
- $specialChars
- $specialCharsReplacement
Methods
private
- changeArrayValuesByAssocArray() — Performs $array[$key] = $value for all $key => $value pairs in $newValues.
- changeArrayValuesToKeys() — Performs $array[$key] = $key for all values in $keys.
- checkActiveOrHistoricCurrencyCode() — Checks if the currency code has a valid format. Also if it has a valid format it has not to exist.
- checkAmountFormat() — Checks if the amount fits the format: A float with only two decimals, not lower than 0.01, not greater than 999,999,999.99.
- checkBoolean() — Checks if $bbi is a valid batch booking indicator. Returns 'true' for "1", "true", "on" and "yes", returns 'false' for "0", "false", "off", "no", and ""
- checkCategoryPurpose()
- checkCharset()
- checkDateFormat()
- checkLength() — Checks if the length of the input string not longer than the entered length
- checkLocalInstrument()
- checkPurpose()
- checkRestrictedIdentificationSEPA1()
- checkRestrictedIdentificationSEPA2()
- checkRestrictedPersonIdentifierSEPA()
- checkSeqType() — Checks if the sequence type is valid.
- dateIsTargetDay() — Checks if $date is a SEPA TARGET day. Every day is a TARGET day except for saturdays, sundays new year's day, good friday, easter monday, the may holiday, first and second christmas holiday.
- getValFromMultiDimInput()
- iso7064Mod97m10ChecksumCheck()
public
- check() — Checks if the input holds for the field.
- checkAndSanitize() — Checks the input and if it is not valid it tries to sanitize it.
- checkAndSanitizeAll()
- checkAndSanitizeInput() — This function checks if the index of the inputArray exists and if the input is valid. The function can be called as `checkAndSanitizeInput($fieldName,$_POST,['input',$fieldName],$flags,$options)` and equals `checkAndSanitize($fieldName,$_POST['input'][$fieldName],$flags,$options)`, but checks first, if the index exists.
- checkBIC() — Checks if a bic is valid. Note that also if the bic is valid it does not have to exist
- checkCreateDateTime() — Checks if the input has the format 'Y-m-d\TH:i:s'
- checkCreditorIdentifier()
- checkIBAN() — Checks if an iban is valid. Note that also if the iban is valid it does not have to exist
- checkInput() — This function checks if the index of the inputArray exists and if the input is valid. The function can be called as `checkInput($fieldName,$_POST,['input',$fieldName],$options)` and equals `check($fieldName,$_POST['input'][$fieldName],$options)`, but checks first, if the index exists.
- checkRequiredCollectionKeys()
- checkRequiredPaymentKeys()
- containsAllKeys() — Checks if $arr misses one of the given $keys
- containsNotAnyKey() — Checks if $arr not contains any key of $keys
- crossCheckIbanBic() — Checks if IBAN and BIC belong to the same country. If not, they also can not belong to each other.
- getDate() — Reformat a date string from a given format to the ISODate format. Notice: 20.13.2014 is valid and becomes 2015-01-20.
- getDateWithMinOffsetFromToday() — Returns the target date, if it has at least the given offset of TARGET2 days form today. Else the earliest date that respects the offset is returned.
- getDateWithOffset() — Computes the next TARGET2 day (including today) with respect to a TARGET2 offset.
- isNationalTransaction() — Checks if both IBANs do belong to the same country.
- replaceSpecialChars() — Replaces all special chars like á, ä, â, à, å, ã, æ, Ç, Ø, Š, ", ’ and & by a latin character.
- sanitize() — Tries to sanitize the the input so it fits in the field.
- sanitizeDateFormat() — Tries to convert the given date into the format YYYY-MM-DD (Y-m-d). Therefor it tries the following input formats in the order of appearance: d.m.Y, d.m.y, j.n.Y, j.n.y, m.d.Y, m.d.y, n.j.Y, n.j.y, Y/m/d, y/m/d, Y/n/j, y/n/j, Y.m.d, y.m.d, Y.n.j, y.n.j.
- sanitizeInput() — This function checks if the index of the inputArray exists and if the input is valid. The function can be called as `sanitizeInput($fieldName,$_POST,['input',$fieldName],$flags)` and equals `sanitize($fieldName,$_POST['input'][$fieldName],$flags)`, but checks first, if the index exists.
- sanitizeLength() — Shortens the input string to the max length if it is to long.
- sanitizeLongText()
- sanitizeShortText()
History
-
2014-10-17T02:04:33+02:00 (commit #7cfe054)
Author: AbcAeffchen (alex@abcaeffchen.net) / Commiter: AbcAeffchen (alex@abcaeffchen.net)
updated readme updated example added documentation
-
2014-10-16T23:50:38+02:00 (commit #ff2b376)
Author: AbcAeffchen (alex@abcaeffchen.net) / Commiter: AbcAeffchen (alex@abcaeffchen.net)
changed namespace to AbcAeffchen\SepaUtilities
-
2014-10-16T23:20:39+02:00 (commit #a95d7fc)
Author: AbcAeffchen (alex@abcaeffchen.net) / Commiter: AbcAeffchen (alex@abcaeffchen.net)
fixed bugs in replaceSpecialChars() added tests for replaceSpecialChars()
-
2014-10-16T18:43:09+02:00 (commit #aa3f838)
Author: AbcAeffchen (alex@abcaeffchen.net) / Commiter: AbcAeffchen (alex@abcaeffchen.net)
changed the signature of getDateWithOffset(), fixed some tests, updated license
-
2014-10-16T17:29:49+02:00 (commit #2ea79ef)
Author: AbcAeffchen (alex@abcaeffchen.net) / Commiter: AbcAeffchen (alex@abcaeffchen.net)
initial commit