Skip to content

Commit 1f601e6

Browse files
committed
add getFunction method
ensures that UnknownFunctionException gets thrown by constructor
1 parent 1edb63a commit 1f601e6

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/AbstractFunction.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,37 @@
2525
abstract class AbstractFunction implements IFunction
2626
{
2727
/**
28-
* @var mixed
28+
* @var mixed PHP module connection ressource/object
2929
*/
3030
protected $connection;
3131

3232
/**
33-
* @var string
33+
* @var mixed PHP module remote function ressource/object
34+
*/
35+
protected $function;
36+
37+
/**
38+
* @var string remote function name
3439
*/
3540
protected $name;
3641

3742
/**
38-
* @var array
43+
* @var array remote function parameters
3944
*/
4045
protected $params;
4146

4247
/**
4348
* Initialize this class with a connection instance and the function name.
44-
* @param mixed $connection Connection ressource/class
49+
* @param mixed $connection Connection resource/object
4550
* @param string $name
51+
* @throws \phpsap\exceptions\UnknownFunctionException
4652
*/
4753
public function __construct($connection, $name)
4854
{
4955
$this->connection = $connection;
5056
$this->name = $name;
5157
$this->reset();
58+
$this->function = $this->getFunction();
5259
}
5360

5461
/**
@@ -90,7 +97,8 @@ public function setParam($name, $value)
9097
}
9198

9299
/**
93-
* Get a parameter previously defined using setParam()
100+
* Get a parameter previously defined using setParam().
101+
* In case the requested parameter has not been set, return the defined default value.
94102
* @param string $name
95103
* @param null $default
96104
* @return mixed|null
@@ -141,4 +149,11 @@ abstract public function __destruct();
141149
* @throws \phpsap\exceptions\FunctionCallException
142150
*/
143151
abstract protected function execute();
152+
153+
/**
154+
* Get the PHP module remote function ressource/object.
155+
* @return mixed
156+
* @throws \phpsap\exceptions\UnknownFunctionException
157+
*/
158+
abstract protected function getFunction();
144159
}

tests/helper/RemoteFunction.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,14 @@ public function getParam($name, $default = null)
7575
{
7676
return parent::getParam($name, $default);
7777
}
78+
79+
/**
80+
* Get the PHP module remote function ressource/object.
81+
* @return mixed
82+
* @throws \phpsap\exceptions\UnknownFunctionException
83+
*/
84+
protected function getFunction()
85+
{
86+
return 'TRBp3hoJ';
87+
}
7888
}

0 commit comments

Comments
 (0)