CashCoupon::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

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
1
<?php
2
3
namespace YEntWeChat\Payment\CashCoupon;
4
5
use YEntWeChat\Payment\Merchant;
6
7
/**
8
 * Class LuckyMoney.
9
 */
10 View Code Duplication
class CashCoupon
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @var API
14
     */
15
    protected $api;
16
17
    /**
18
     * Merchant instance.
19
     *
20
     * @var \EntWeChat\Payment\Merchant
21
     */
22
    protected $merchant;
23
24
    /**
25
     * Constructor.
26
     *
27
     * @param Merchant $merchant
28
     */
29
    public function __construct(Merchant $merchant)
30
    {
31
        $this->merchant = $merchant;
0 ignored issues
show
Documentation Bug introduced by
It seems like $merchant of type object<YEntWeChat\Payment\Merchant> is incompatible with the declared type object<EntWeChat\Payment\Merchant> of property $merchant.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
32
    }
33
34
    /**
35
     * Merchant setter.
36
     *
37
     * @param Merchant $merchant
38
     */
39
    public function setMerchant(Merchant $merchant)
40
    {
41
        $this->merchant = $merchant;
0 ignored issues
show
Documentation Bug introduced by
It seems like $merchant of type object<YEntWeChat\Payment\Merchant> is incompatible with the declared type object<EntWeChat\Payment\Merchant> of property $merchant.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
    }
43
44
    /**
45
     * Merchant getter.
46
     *
47
     * @return Merchant
48
     */
49
    public function getMerchant()
50
    {
51
        return $this->merchant;
52
    }
53
54
    /**
55
     * API setter.
56
     *
57
     * @param API $api
58
     */
59
    public function setAPI(API $api)
60
    {
61
        $this->api = $api;
62
    }
63
64
    /**
65
     * Return API instance.
66
     *
67
     * @return API
68
     */
69
    public function getAPI()
70
    {
71
        return $this->api ?: $this->api = new API($this->getMerchant());
72
    }
73
74
    /**
75
     * Magic call.
76
     *
77
     * @param string $method
78
     * @param array  $args
79
     *
80
     * @return mixed
81
     *
82
     * @codeCoverageIgnore
83
     */
84
    public function __call($method, $args)
85
    {
86
        if (is_callable([$this->getAPI(), $method])) {
87
            return call_user_func_array([$this->api, $method], $args);
88
        }
89
    }
90
}
91