| @@ 29-109 (lines=81) @@ | ||
| 26 | /** |
|
| 27 | * Class LuckyMoney. |
|
| 28 | */ |
|
| 29 | class LuckyMoney |
|
| 30 | { |
|
| 31 | /** |
|
| 32 | * @var API |
|
| 33 | */ |
|
| 34 | protected $api; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Merchant instance. |
|
| 38 | * |
|
| 39 | * @var \EasyWeChat\Payment\Merchant |
|
| 40 | */ |
|
| 41 | protected $merchant; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Constructor. |
|
| 45 | * |
|
| 46 | * @param Merchant $merchant |
|
| 47 | */ |
|
| 48 | public function __construct(Merchant $merchant) |
|
| 49 | { |
|
| 50 | $this->merchant = $merchant; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Merchant setter. |
|
| 55 | * |
|
| 56 | * @param Merchant $merchant |
|
| 57 | */ |
|
| 58 | public function setMerchant(Merchant $merchant) |
|
| 59 | { |
|
| 60 | $this->merchant = $merchant; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Merchant getter. |
|
| 65 | * |
|
| 66 | * @return Merchant |
|
| 67 | */ |
|
| 68 | public function getMerchant() |
|
| 69 | { |
|
| 70 | return $this->merchant; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * API setter. |
|
| 75 | * |
|
| 76 | * @param API $api |
|
| 77 | */ |
|
| 78 | public function setAPI(API $api) |
|
| 79 | { |
|
| 80 | $this->api = $api; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Return API instance. |
|
| 85 | * |
|
| 86 | * @return API |
|
| 87 | */ |
|
| 88 | public function getAPI() |
|
| 89 | { |
|
| 90 | return $this->api ?: $this->api = new API($this->getMerchant()); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Magic call. |
|
| 95 | * |
|
| 96 | * @param string $method |
|
| 97 | * @param array $args |
|
| 98 | * |
|
| 99 | * @return mixed |
|
| 100 | * |
|
| 101 | * @codeCoverageIgnore |
|
| 102 | */ |
|
| 103 | public function __call($method, $args) |
|
| 104 | { |
|
| 105 | if (is_callable([$this->getAPI(), $method])) { |
|
| 106 | return call_user_func_array([$this->api, $method], $args); |
|
| 107 | } |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||
| @@ 29-109 (lines=81) @@ | ||
| 26 | /** |
|
| 27 | * Class MerchantPay. |
|
| 28 | */ |
|
| 29 | class MerchantPay |
|
| 30 | { |
|
| 31 | /** |
|
| 32 | * @var API |
|
| 33 | */ |
|
| 34 | protected $api; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Merchant instance. |
|
| 38 | * |
|
| 39 | * @var \EasyWeChat\Payment\Merchant |
|
| 40 | */ |
|
| 41 | protected $merchant; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Constructor. |
|
| 45 | * |
|
| 46 | * @param Merchant $merchant |
|
| 47 | */ |
|
| 48 | public function __construct(Merchant $merchant) |
|
| 49 | { |
|
| 50 | $this->merchant = $merchant; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Merchant setter. |
|
| 55 | * |
|
| 56 | * @param Merchant $merchant |
|
| 57 | */ |
|
| 58 | public function setMerchant(Merchant $merchant) |
|
| 59 | { |
|
| 60 | $this->merchant = $merchant; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Merchant getter. |
|
| 65 | * |
|
| 66 | * @return Merchant |
|
| 67 | */ |
|
| 68 | public function getMerchant() |
|
| 69 | { |
|
| 70 | return $this->merchant; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * API setter. |
|
| 75 | * |
|
| 76 | * @param API $api |
|
| 77 | */ |
|
| 78 | public function setAPI(API $api) |
|
| 79 | { |
|
| 80 | $this->api = $api; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Return API instance. |
|
| 85 | * |
|
| 86 | * @return API |
|
| 87 | */ |
|
| 88 | public function getAPI() |
|
| 89 | { |
|
| 90 | return $this->api ?: $this->api = new API($this->getMerchant()); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Magic call. |
|
| 95 | * |
|
| 96 | * @param string $method |
|
| 97 | * @param array $args |
|
| 98 | * |
|
| 99 | * @return mixed |
|
| 100 | * |
|
| 101 | * @codeCoverageIgnore |
|
| 102 | */ |
|
| 103 | public function __call($method, $args) |
|
| 104 | { |
|
| 105 | if (is_callable([$this->getAPI(), $method])) { |
|
| 106 | return call_user_func_array([$this->api, $method], $args); |
|
| 107 | } |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||
| @@ 29-109 (lines=81) @@ | ||
| 26 | /** |
|
| 27 | * Class LuckyMoney. |
|
| 28 | */ |
|
| 29 | class CashCoupon |
|
| 30 | { |
|
| 31 | /** |
|
| 32 | * @var API |
|
| 33 | */ |
|
| 34 | protected $api; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Merchant instance. |
|
| 38 | * |
|
| 39 | * @var \EasyWeChat\Payment\Merchant |
|
| 40 | */ |
|
| 41 | protected $merchant; |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Constructor. |
|
| 45 | * |
|
| 46 | * @param Merchant $merchant |
|
| 47 | */ |
|
| 48 | public function __construct(Merchant $merchant) |
|
| 49 | { |
|
| 50 | $this->merchant = $merchant; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Merchant setter. |
|
| 55 | * |
|
| 56 | * @param Merchant $merchant |
|
| 57 | */ |
|
| 58 | public function setMerchant(Merchant $merchant) |
|
| 59 | { |
|
| 60 | $this->merchant = $merchant; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * Merchant getter. |
|
| 65 | * |
|
| 66 | * @return Merchant |
|
| 67 | */ |
|
| 68 | public function getMerchant() |
|
| 69 | { |
|
| 70 | return $this->merchant; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * API setter. |
|
| 75 | * |
|
| 76 | * @param API $api |
|
| 77 | */ |
|
| 78 | public function setAPI(API $api) |
|
| 79 | { |
|
| 80 | $this->api = $api; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Return API instance. |
|
| 85 | * |
|
| 86 | * @return API |
|
| 87 | */ |
|
| 88 | public function getAPI() |
|
| 89 | { |
|
| 90 | return $this->api ?: $this->api = new API($this->getMerchant()); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Magic call. |
|
| 95 | * |
|
| 96 | * @param string $method |
|
| 97 | * @param array $args |
|
| 98 | * |
|
| 99 | * @return mixed |
|
| 100 | * |
|
| 101 | * @codeCoverageIgnore |
|
| 102 | */ |
|
| 103 | public function __call($method, $args) |
|
| 104 | { |
|
| 105 | if (is_callable([$this->getAPI(), $method])) { |
|
| 106 | return call_user_func_array([$this->api, $method], $args); |
|
| 107 | } |
|
| 108 | } |
|
| 109 | } |
|
| 110 | ||