-
Notifications
You must be signed in to change notification settings - Fork 1
/
TwoCheckoutAdapter.php
37 lines (32 loc) · 1 KB
/
TwoCheckoutAdapter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace yii\twocheckout;
abstract class TwoCheckoutAdapter
{
/**
* Must be overridden in children classes
*/
protected $instanceClassName = null;
/**
* Magic call method
*
* @access public
* @param $name
* @param $arguments
* @return mixed
* @throws TwoCheckoutException
*/
public function __call($name, $arguments)
{
if (method_exists($this, $name)) {
return call_user_func_array([$this, $name], $arguments);
}
if (!$this->instanceClassName || !class_exists($this->instanceClassName)) {
throw new TwoCheckoutException('Twocheckout library class name should not be empty or not exists');
}
if (!method_exists($this->instanceClassName, $name)) {
throw new TwoCheckoutException("Method {$name} is not supported");
}
return call_user_func_array([$this->instanceClassName, $name], $arguments);
}
}
class TwoCheckoutException extends \Twocheckout_Error{}