Skip to content

Commit

Permalink
[LIBSDK-12] fix missing SEPA form on installment-directdebit
Browse files Browse the repository at this point in the history
  • Loading branch information
rpWelschlau committed Apr 10, 2017
1 parent a3a8958 commit 4293ed1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Frontend/InstallmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getInstallmentCalculatorByTemplate($amount, $template)
['rp_minimumRate' => $configuration->getMinRate()],
['rp_maximumRate' => $configuration->getMaxRate($amount)],
['rp_amount' => $amount],
$this->getDebitPayType($configuration->getValidPaymentFirstdays()), // Necessary here or just trough if-statementer
$this->getDebitPayType($configuration->getValidPaymentFirstdays()),
$this->lang->getArray()
);

Expand Down Expand Up @@ -340,7 +340,7 @@ private function getDebitPayType($validPaymentFirstdays)

if (is_array($validPaymentFirstdays)) {
foreach ($validPaymentFirstdays as $validPaymentFirstday) {
$result = array_merge($result, $this->getDebitPayType($validPaymentFirstday));
$result = Util::merge_array_replace($result, $this->getDebitPayType($validPaymentFirstday));
}
} else {
if (key_exists($validPaymentFirstdays, CONSTANTS::DEBIT_PAY_TYPES)) {
Expand Down
31 changes: 28 additions & 3 deletions src/Service/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static function changeCamelCaseToDash($string)
* @param string $case
* @return string
*/
private static function changeCase($string, $delimiter, $case = '') {
private static function changeCase($string, $delimiter, $case = '')
{
$stringFormatted = preg_split('/(?=[A-Z])/', $string, -1, PREG_SPLIT_NO_EMPTY);
$stringFormatted = implode($delimiter, $stringFormatted);
if ($case == 'upper') {
Expand Down Expand Up @@ -114,6 +115,30 @@ public static function templateLoop($template, $loopDataSet)
return $tpl;
}

/**
* Merges all entered array and replaces multiple keys by highest value
*
* @param array
* @return array
*/
public static function merge_array_replace()
{
$inputArrays = func_get_args();
$outputArray = [];

foreach ($inputArrays as $array) {
foreach ($array as $key => $value) {
if (!key_exists($key, $outputArray)) {
$outputArray[$key] = $value;
} elseif ((int) $value > (int) $outputArray[$key]) {
$outputArray[$key] = $value;
}
}
}

return $outputArray;
}

/**
* Splits entered string by delimiter commands
*
Expand All @@ -122,7 +147,8 @@ public static function templateLoop($template, $loopDataSet)
* @param string $cmdEnd
* @return array
*/
private static function splitStringByCommand($template, $cmdBegin, $cmdEnd) {
private static function splitStringByCommand($template, $cmdBegin, $cmdEnd)
{
$tplPreText = strstr($template, $cmdBegin, true); // Get part before cmdBegin
$tplPosTextBegin = strpos($template, $cmdBegin) + strlen($cmdBegin); // Get innerText starting position
$tplTextContent = strstr(substr($template, $tplPosTextBegin), $cmdEnd, true); // Get innerText
Expand All @@ -135,5 +161,4 @@ private static function splitStringByCommand($template, $cmdBegin, $cmdEnd) {
'postText' => $tplPostText
];
}

}

0 comments on commit 4293ed1

Please sign in to comment.