NotificationRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendData() 0 4 1
A getIncomingParameters() 0 15 2
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\Message\QRCode;
9
10
use Omnipay\MoMo\Message\AbstractIncomingRequest;
11
12
/**
13
 * @author Vuong Minh <[email protected]>
14
 * @since 1.0.0
15
 */
16
class NotificationRequest extends AbstractIncomingRequest
17
{
18
    /**
19
     * {@inheritdoc}
20
     * @throws \Omnipay\Common\Exception\InvalidResponseException
21
     */
22
    public function sendData($data): NotificationResponse
23
    {
24
        return $this->response = new NotificationResponse($this, $data);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function getIncomingParameters(): array
31
    {
32
        $data = [];
33
        $requestData = json_decode($this->httpRequest->getContent(), true) ?? [];
34
        $parameters = [
35
            'accessKey', 'amount', 'message', 'momoTransId', 'partnerCode', 'partnerRefId', 'partnerTransId',
36
            'responseTime', 'status', 'storeId', 'transType', 'signature',
37
        ];
38
39
        foreach ($parameters as $parameter) {
40
            $data[$parameter] = $requestData[$parameter] ?? null;
41
        }
42
43
        return $data;
44
    }
45
}
46