QRCodeGateway   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A notification() 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\QRCode\NotificationRequest;
15
16
/**
17
 * @author Vuong Minh <[email protected]>
18
 * @since 1.0.0
19
 */
20 View Code Duplication
class QRCodeGateway 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 QRCode';
30
    }
31
32
    /**
33
     * Tạo request notification gửi từ MoMo.
34
     *
35
     * @param  array  $options
36
     * @return \Omnipay\Common\Message\RequestInterface|NotificationRequest
37
     */
38
    public function notification(array $options = []): NotificationRequest
39
    {
40
        return $this->createRequest(NotificationRequest::class, $options);
41
    }
42
43
    /**
44
     * Tạo yêu cầu xác nhận hoàn thành hoặc hủy bỏ giao dịch đến MoMo.
45
     *
46
     * @param  array  $options
47
     * @return \Omnipay\Common\Message\RequestInterface|PayConfirmRequest
48
     */
49
    public function payConfirm(array $options = []): PayConfirmRequest
50
    {
51
        return $this->createRequest(PayConfirmRequest::class, $options);
52
    }
53
54
    /**
55
     * Tạo yêu cầu truy vấn thông tin giao dịch đến MoMo.
56
     *
57
     * @param  array  $options
58
     * @return \Omnipay\Common\Message\RequestInterface|PayQueryStatusRequest
59
     */
60
    public function queryTransaction(array $options = []): PayQueryStatusRequest
61
    {
62
        return $this->createRequest(PayQueryStatusRequest::class, $options);
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     * @return \Omnipay\Common\Message\RequestInterface|PayRefundRequest
68
     */
69
    public function refund(array $options = []): PayRefundRequest
70
    {
71
        return $this->createRequest(PayRefundRequest::class, $options);
72
    }
73
}
74