AppInAppGateway   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 52
loc 52
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A purchase() 4 4 1
A payConfirm() 4 4 1
A queryTransaction() 4 4 1
A refund() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-momo
4
 * @copyright (c) PHP Viet
5
 * @license [MIT](http://www.opensource.org/licenses/MIT)
6
 */
7
8
namespace Omnipay\MoMo;
9
10
use Omnipay\Common\AbstractGateway;
11
use Omnipay\MoMo\Message\PayRefundRequest;
12
use Omnipay\MoMo\Message\PayConfirmRequest;
13
use Omnipay\MoMo\Message\PayQueryStatusRequest;
14
use Omnipay\MoMo\Message\AppInApp\PurchaseRequest;
15
16
/**
17
 * @author Vuong Minh <[email protected]>
18
 * @since 1.0.0
19
 */
20 View Code Duplication
class AppInAppGateway extends AbstractGateway
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...
21
{
22
    use Concerns\Parameters;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getName(): string
28
    {
29
        return 'MoMo AIA';
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     * @return \Omnipay\Common\Message\RequestInterface|PurchaseRequest
35
     */
36
    public function purchase(array $options = []): PurchaseRequest
37
    {
38
        return $this->createRequest(PurchaseRequest::class, $options);
39
    }
40
41
    /**
42
     * Tạo yêu cầu xác nhận hoàn thành hoặc hủy bỏ giao dịch đến MoMo.
43
     *
44
     * @param  array  $options
45
     * @return \Omnipay\Common\Message\RequestInterface|PayConfirmRequest
46
     */
47
    public function payConfirm(array $options = []): PayConfirmRequest
48
    {
49
        return $this->createRequest(PayConfirmRequest::class, $options);
50
    }
51
52
    /**
53
     * Tạo yêu cầu truy vấn thông tin giao dịch đến MoMo.
54
     *
55
     * @param  array  $options
56
     * @return \Omnipay\Common\Message\RequestInterface|PayQueryStatusRequest
57
     */
58
    public function queryTransaction(array $options = []): PayQueryStatusRequest
59
    {
60
        return $this->createRequest(PayQueryStatusRequest::class, $options);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     * @return \Omnipay\Common\Message\RequestInterface|PayRefundRequest
66
     */
67
    public function refund(array $options = []): PayRefundRequest
68
    {
69
        return $this->createRequest(PayRefundRequest::class, $options);
70
    }
71
}
72