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

OldPurchaseRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 2
cbo 2
dl 0
loc 53
ccs 25
cts 25
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaggageFields() 0 4 1
B getData() 0 29 4
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 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