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

OldPurchaseRequest::getData()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 29
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
ccs 21
cts 21
cp 1
rs 8.5806
cc 4
eloc 18
nc 8
nop 0
crap 4
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 OldPurchaseRequest
16
 * Implements request for APIv1.
17
 */
18
class OldPurchaseRequest extends AbstractRequest
19
{
20
    /**
21
     * @return string
22
     */
23 2
    public function getBaggageFields()
24
    {
25 2
        return $this->getCurrency() . ' ' . $this->username;
0 ignored issues
show
Bug introduced by
The property username does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function getData()
32
    {
33 2
        $this->validate('checkoutId', 'amount', 'currency', 'description', 'transactionId');
34
35
        $return = [
36 2
            'ik_shop_id' => $this->getCheckoutId(),
37 2
            'ik_payment_amount' => $this->getAmount(),
38 2
            'ik_payment_id' => $this->getTransactionId(),
39 2
            'ik_payment_desc' => $this->getDescription(),
40 2
            'ik_baggage_fields' => $this->getBaggageFields(),
41 2
        ];
42
43 2
        if ($ik_success_url = $this->getReturnUrl()) {
44 2
            $return['ik_success_url'] = $ik_success_url;
45 2
            $return['ik_success_method'] = $this->getReturnMethod();
46 2
        }
47
48 2
        if ($ik_fail_method = $this->getCancelUrl()) {
49 2
            $return['ik_fail_url'] = $ik_fail_method;
50 2
            $return['ik_fail_method'] = $this->getCancelMethod();
51 2
        }
52
53 2
        if ($ik_status_url = $this->getNotifyUrl()) {
54 2
            $return['ik_status_url'] = $ik_status_url;
55 2
            $return['ik_status_method'] = $this->getNotifyMethod();
56 2
        }
57
58 2
        return $return;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     * @param mixed $data
64
     * @return PurchaseResponse
65
     */
66 1
    public function sendData($data)
67
    {
68 1
        return $this->response = new PurchaseResponse($this, $data);
69
    }
70
}
71