Skip to content

Commit 42318b6

Browse files
committed
implement getFunction() according to common lib
Ensures that UnknownFunctionException gets thrown by constructor. Fix broken tests because of changes in mandatory parameter list on the way.
1 parent 83c7a2c commit 42318b6

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SapRfcFunction.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
*/
2828
class SapRfcFunction extends AbstractFunction
2929
{
30+
/**
31+
* @var \sapnwrfc
32+
*/
33+
protected $connection;
34+
3035
/**
3136
* @var \sapnwrfc_function
3237
*/
@@ -51,9 +56,8 @@ public function __destruct()
5156
*/
5257
protected function execute()
5358
{
54-
$function = $this->getFunction();
5559
try {
56-
$result = $function->invoke($this->params);
60+
$result = $this->function->invoke($this->params);
5761
} catch (\Exception $exception) {
5862
throw new FunctionCallException(sprintf(
5963
'Function call %s failed: %s',
@@ -67,22 +71,19 @@ protected function execute()
6771
/**
6872
* Lookup SAP remote function and return an module class instance of it.
6973
* @return \sapnwrfc_function
70-
* @throws \phpsap\exceptions\FunctionCallException
74+
* @throws \phpsap\exceptions\UnknownFunctionException
7175
*/
7276
protected function getFunction()
7377
{
74-
if ($this->function === null) {
75-
try {
76-
$this->function = $this->connection->function_lookup($this->getName());
77-
} catch (\Exception $exception) {
78-
throw new UnknownFunctionException(sprintf(
79-
'Unknown function %s: %s',
80-
$this->getName(),
81-
$exception->getMessage()
82-
), 0, $exception);
83-
}
78+
try {
79+
return $this->connection->function_lookup($this->getName());
80+
} catch (\Exception $exception) {
81+
throw new UnknownFunctionException(sprintf(
82+
'Unknown function %s: %s',
83+
$this->getName(),
84+
$exception->getMessage()
85+
), 0, $exception);
8486
}
85-
return $this->function;
8687
}
8788

8889
/**

0 commit comments

Comments
 (0)