AbstractIncomingRequest::initialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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;
9
10
/**
11
 * @author Vuong Minh <[email protected]>
12
 * @since 1.0.0
13
 */
14
abstract class AbstractIncomingRequest extends AbstractRequest
15
{
16
    /**
17
     * {@inheritdoc}
18
     * @throws \Omnipay\Common\Exception\InvalidRequestException
19
     */
20
    public function getData(): array
21
    {
22
        call_user_func_array(
23
            [$this, 'validate'],
24
            array_keys($parameters = $this->getIncomingParameters())
25
        );
26
27
        return $parameters;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function initialize(array $parameters = [])
34
    {
35
        parent::initialize($parameters);
36
37
        foreach ($this->getIncomingParameters() as $parameter => $value) {
38
            $this->setParameter($parameter, $value);
39
        }
40
41
        return $this;
42
    }
43
44
    /**
45
     * Trả về danh sách parameters từ MoMo gửi sang.
46
     *
47
     * @return array
48
     */
49
    abstract protected function getIncomingParameters(): array;
50
}
51