Completed
Push — master ( 891443...e38f5c )
by Carlos
03:00
created

CashCoupon::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 0
cp 0
crap 6
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
/**
13
 * LuckyMoney.php.
14
 *
15
 * @author    tianyong90 <[email protected]>
16
 * @copyright 2015 overtrue <[email protected]>
17
 *
18
 * @see      https://github.com/overtrue
19
 * @see      http://overtrue.me
20
 */
21
22
namespace EasyWeChat\Payment\CashCoupon;
23
24
use EasyWeChat\Payment\Merchant;
25
26
/**
27
 * Class LuckyMoney.
28
 */
29 View Code Duplication
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