IncomingRequest::getIncomingParameters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * @link https://github.com/phpviet/omnipay-vnpay
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace Omnipay\VNPay\Message;
10
11
use Omnipay\Common\Message\AbstractRequest;
12
use Omnipay\VNPay\Concerns\Parameters;
13
use Omnipay\VNPay\Concerns\ParametersNormalization;
14
15
/**
16
 * @author Vuong Minh <[email protected]>
17
 * @since 1.0.0
18
 */
19
class IncomingRequest extends AbstractRequest
20
{
21
    use Parameters;
22
    use ParametersNormalization;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getData(): array
28
    {
29
        call_user_func_array(
30
            [$this, 'validate'],
31
            array_keys($parameters = $this->getIncomingParameters())
32
        );
33
34
        return $parameters;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     * @throws \Omnipay\Common\Exception\InvalidResponseException
40
     */
41
    public function sendData($data): SignatureResponse
42
    {
43
        return $this->response = new SignatureResponse($this, $data);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function initialize(array $parameters = [])
50
    {
51
        parent::initialize(
52
            $this->normalizeParameters($parameters)
53
        );
54
55
        foreach ($this->getIncomingParameters() as $parameter => $value) {
56
            $this->setParameter($parameter, $value);
57
        }
58
59
        return $this;
60
    }
61
62
    /**
63
     * Trả về danh sách parameters từ VNPay gửi sang.
64
     *
65
     * @return array
66
     */
67
    protected function getIncomingParameters(): array
68
    {
69
        return $this->httpRequest->query->all();
70
    }
71
}
72