Passed
Push — master ( 535bd5...f77f61 )
by wannanbigpig
03:11
created

Application   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 62
ccs 8
cts 10
cp 0.8
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 1
A setNotifyUrl() 0 5 1
A handleNotify() 0 3 1
A setReturnUrl() 0 5 1
1
<?php
2
/*
3
 * This file is part of the wannanbigpig/alipay-sdk-php.
4
 *
5
 * (c) wannanbigpig <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace EasyAlipay\Payment;
12
13
use Closure;
14
use EasyAlipay\Kernel\ServiceContainer;
15
use EasyAlipay\Payment\Notify\Handle;
16
17
/**
18
 * Class Application
19
 *
20
 * @author   liuml  <[email protected]>
21
 * @DateTime 2019-07-18  16:13
22
 *
23
 * @property Pay\Client    $pay
24
 * @property Refund\Client $refund
25
 * @property Bill\Client   $bill
26
 *
27
 * @method mixed pay(array $params)
28
 * @method mixed create(array $params)
29
 * @method mixed preCreate(array $params)
30
 * @method mixed close(string $tradeNo, string $outTradeNo = null, string $operatorId = null)
31
 * @method mixed refund(string $tradeNo, $amount, string $outTradeNo = null, array $params = [])
32
 * @method mixed query(string $tradeNo, string $outTradeNo = null, string $orgPid = null)
33
 * @method mixed cancel(string $tradeNo, string $outTradeNo = null)
34
 * @method mixed orderSettle(string $outRequestNo, string $tradeNo, array $royaltyParameters, string $operatorId = null)
35
 * @method mixed orderInfoSync(string $tradeNo, string $outRequestNo, string $bizType, string $origRequestNo = null, string $orderBizInfo = null)
36
 */
37
class Application extends ServiceContainer
38
{
39
40
    /**
41
     * @var array
42
     */
43
    protected $providers = [
44
        'base' => Base\Client::class,
45
        'pay' => Pay\Client::class,
46
        'refund' => Refund\Client::class,
47
        'bill' => Bill\Client::class,
48
    ];
49
50
    /**
51
     * @param string $name
52
     * @param array  $arguments
53
     *
54
     * @return mixed
55
     */
56
    public function __call($name, $arguments)
57
    {
58
        return call_user_func_array([$this['base'], $name], $arguments);
59
    }
60
61
    /**
62
     * setNotifyUrl.
63
     *
64
     * @param string $notifyUrl
65
     *
66
     * @return $this
67
     */
68 10
    public function setNotifyUrl(string $notifyUrl)
69
    {
70 10
        $this->config->set('notify_url', $notifyUrl);
71
72 10
        return $this;
73
    }
74
75
    /**
76
     * setReturnUrl.
77
     *
78
     * @param string $returnUrl
79
     *
80
     * @return $this
81
     */
82 10
    public function setReturnUrl(string $returnUrl)
83
    {
84 10
        $this->config->set('return_url', $returnUrl);
85
86 10
        return $this;
87
    }
88
89
    /**
90
     * handleNotify.
91
     *
92
     * @param \Closure $closure
93
     *
94
     * @return \Symfony\Component\HttpFoundation\Response
95
     */
96 10
    public function handleNotify(Closure $closure)
97
    {
98 10
        return (new Handle($this))->run($closure);
99
    }
100
}
101