Skip to content

Commit 557724c

Browse files
committed
move actual string trimming to separate function
1 parent b52baa7 commit 557724c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/SapRfcFunction.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ protected function getFunction()
9595
protected function trimStrings($return)
9696
{
9797
if (is_string($return)) {
98-
/**
99-
* Do not trim strings containing line breaks.
100-
*/
101-
if (strpos($return, "\n") !== false
102-
|| strpos($return, "\r\n") !== false
103-
) {
104-
return $return;
105-
}
106-
return rtrim($return);
98+
return $this->rTrim($return);
10799
}
108100
if (is_array($return)) {
109101
foreach ($return as $key => $value) {
@@ -112,4 +104,22 @@ protected function trimStrings($return)
112104
}
113105
return $return;
114106
}
107+
108+
/**
109+
* Trim a string.
110+
* @param string $string
111+
* @return string
112+
*/
113+
protected function rTrim($string)
114+
{
115+
/**
116+
* Do not trim strings containing line breaks.
117+
*/
118+
if (strpos($string, "\n") !== false
119+
|| strpos($string, "\r\n") !== false
120+
) {
121+
return $string;
122+
}
123+
return rtrim($string);
124+
}
115125
}

0 commit comments

Comments
 (0)