CompletePurchaseRequest::getData()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.6666
c 0
b 0
f 0
cc 4
nc 6
nop 0
crap 4
1
<?php
2
/**
3
 * InterKassa driver for the Omnipay PHP payment processing library
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-interkassa
6
 * @package   omnipay-interkassa
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\InterKassa\Message;
12
13
use Omnipay\Common\Exception\InvalidResponseException;
14
15
/**
16
 * InterKassa Complete Purchase Request.
17
 */
18
class CompletePurchaseRequest extends AbstractRequest
19
{
20
    /**
21
     * Get the data for this request.
22
     * @throws InvalidResponseException
23
     * @throws \Omnipay\Common\Exception\InvalidRequestException
24
     * @return array request data
25
     */
26 12
    public function getData()
27
    {
28 12
        if ($this->getTestMode()) {
29 2
            $this->validate('testKey');
30
        } else {
31 10
            $this->validate('signKey');
32
        }
33
34 12
        $result = [];
35 12
        $vars = array_merge($this->httpRequest->query->all(), $this->httpRequest->request->all());
36 12
        foreach ($vars as $key => $parameter) {
37 12
            if (strpos($key, 'ik_') === 0) {
38 12
                $result[$key] = $parameter;
39
            }
40
        }
41
42 12
        return $result;
43
    }
44
45
    /**
46
     * Send the request with specified data.
47
     *
48
     * @param mixed $data The data to send
49
     *
50
     * @return CompletePurchaseResponse
51
     */
52 4
    public function sendData($data)
53
    {
54 4
        return $this->response = new CompletePurchaseResponse($this, $data);
55
    }
56
}
57