Completed
Push — master ( 8fe2d8...225854 )
by Andrii
20:54 queued 20:54
created

PurchaseRequest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 78.95%

Importance

Changes 6
Bugs 0 Features 2
Metric Value
wmc 11
c 6
b 0
f 2
lcom 2
cbo 2
dl 0
loc 66
ccs 30
cts 38
cp 0.7895
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
C getData() 0 50 10
A sendData() 0 4 1
1
<?php
2
3
/*
4
 * InterKassa driver for the Omnipay PHP payment processing library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-interkassa
7
 * @package   omnipay-interkassa
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\InterKassa\Message;
13
14
/**
15
 * Class PurchaseRequest.
16
 */
17
class PurchaseRequest extends AbstractRequest
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 1
    public function getData()
23
    {
24 1
        $this->validate('checkoutId', 'amount', 'currency', 'description', 'transactionId');
25
26
        $return = [
27 1
            'ik_co_id'          => $this->getCheckoutId(),
28 1
            'ik_am'             => $this->getAmount(),
29 1
            'ik_pm_no'          => $this->getTransactionId(),
30 1
            'ik_desc'           => $this->getDescription(),
31 1
            'ik_cur'            => $this->getCurrency(),
32 1
        ];
33
34 1
        if ($ik_pnd_u = $this->getReturnUrl()) {
35 1
            $return['ik_pnd_u'] = $ik_pnd_u;
36
37 1
            if ($ik_pnd_m = $this->getReturnMethod()) {
38
                $return['ik_pnd_m'] = $ik_pnd_m;
39
            }
40 1
        }
41
42 1
        if ($ik_suc_u = $this->getReturnUrl()) {
43 1
            $return['ik_suc_u'] = $ik_suc_u;
44
45 1
            if ($ik_suc_m = $this->getReturnMethod()) {
46
                $return['ik_suc_m'] = $ik_suc_m;
47
            }
48 1
        }
49
50 1
        if ($ik_fal_u = $this->getCancelUrl()) {
51 1
            $return['ik_fal_u'] = $ik_fal_u;
52
53 1
            if ($ik_fal_m = $this->getCancelMethod()) {
54
                $return['ik_fal_m'] = $ik_fal_m;
55
            }
56 1
        }
57
58 1
        if ($ik_ia_u = $this->getNotifyUrl()) {
59 1
            $return['ik_ia_u'] = $ik_ia_u;
60
61 1
            if ($ik_ia_m = $this->getNotifyMethod()) {
62
                $return['ik_ia_m'] = $ik_ia_m;
63
            }
64 1
        }
65
66 1
        if ($this->getSecret()) {
67 1
            $return['ik_sign'] = $this->calculateSign($return);
68 1
        }
69
70 1
        return $return;
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     * @param mixed $data
76
     * @return PurchaseResponse
77
     */
78 1
    public function sendData($data)
79
    {
80 1
        return $this->response = new PurchaseResponse($this, $data);
81
    }
82
}
83