AbstractIncomingRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 10 2
A getData() 0 6 1
A sendData() 0 4 1
getIncomingParameters() 0 1 ?
1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-vtcpay
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace Omnipay\VTCPay\Message;
10
11
/**
12
 * @author Vuong Minh <[email protected]>
13
 * @since 1.0.0
14
 */
15
abstract class AbstractIncomingRequest extends AbstractRequest
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function initialize(array $parameters = [])
21
    {
22
        parent::initialize($parameters);
23
24
        foreach ($this->getIncomingParameters() as $parameter => $value) {
25
            $this->setParameter($parameter, $value);
26
        }
27
28
        return $this;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     * @throws \Omnipay\Common\Exception\InvalidRequestException
34
     */
35
    public function getData(): array
36
    {
37
        $this->validate('signature');
38
39
        return $this->getIncomingParameters();
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     * @throws \Omnipay\Common\Exception\InvalidResponseException
45
     */
46
    public function sendData($data): IncomingResponse
47
    {
48
        return $this->response = new IncomingResponse($this, $data);
49
    }
50
51
    /**
52
     * Trả về danh sách parameters từ VTCPay gửi sang.
53
     *
54
     * @return array
55
     */
56
    abstract protected function getIncomingParameters(): array;
57
}
58