IncomingRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

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

4 Methods

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