Completed
Push — master ( 1b7afa...9fbca5 )
by Dmitry
03:33
created

PurchaseRequest::getData()   C

Complexity

Conditions 10
Paths 162

Size

Total Lines 50
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 36
CRAP Score 10

Importance

Changes 8
Bugs 0 Features 4
Metric Value
c 8
b 0
f 4
dl 0
loc 50
ccs 36
cts 36
cp 1
rs 5.4285
cc 10
eloc 27
nc 162
nop 0
crap 10

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 2
    public function getData()
23
    {
24 2
        $this->validate('checkoutId', 'signKey', 'amount', 'currency', 'description', 'transactionId');
25
26
        $return = [
27 2
            'ik_co_id'          => $this->getCheckoutId(),
28 2
            'ik_am'             => $this->getAmount(),
29 2
            'ik_pm_no'          => $this->getTransactionId(),
30 2
            'ik_desc'           => $this->getDescription(),
31 2
            'ik_cur'            => $this->getCurrency(),
32 2
        ];
33
34 2
        if ($ik_pnd_u = $this->getReturnUrl()) {
35 2
            $return['ik_pnd_u'] = $ik_pnd_u;
36
37 2
            if ($ik_pnd_m = $this->getReturnMethod()) {
38 2
                $return['ik_pnd_m'] = $ik_pnd_m;
39 2
            }
40 2
        }
41
42 2
        if ($ik_suc_u = $this->getReturnUrl()) {
43 2
            $return['ik_suc_u'] = $ik_suc_u;
44
45 2
            if ($ik_suc_m = $this->getReturnMethod()) {
46 2
                $return['ik_suc_m'] = $ik_suc_m;
47 2
            }
48 2
        }
49
50 2
        if ($ik_fal_u = $this->getCancelUrl()) {
51 2
            $return['ik_fal_u'] = $ik_fal_u;
52
53 2
            if ($ik_fal_m = $this->getCancelMethod()) {
54 2
                $return['ik_fal_m'] = $ik_fal_m;
55 2
            }
56 2
        }
57
58 2
        if ($ik_ia_u = $this->getNotifyUrl()) {
59 2
            $return['ik_ia_u'] = $ik_ia_u;
60
61 2
            if ($ik_ia_m = $this->getNotifyMethod()) {
62 2
                $return['ik_ia_m'] = $ik_ia_m;
63 2
            }
64 2
        }
65
66 2
        if ($signKey = $this->getSignKey()) {
67 2
            $return['ik_sign'] = $this->calculateSign($return, $signKey);
68 2
        }
69
70 2
        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