Completed
Push — master ( 35e829...731b5b )
by Marco
01:15
created

PaymentRequest   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Importance

Changes 0
Metric Value
wmc 16
lcom 3
cbo 2
dl 0
loc 87
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
B getData() 0 34 6
A getMetaDataId() 0 4 1
A setMetaDataId() 0 4 1
A getBasketId() 0 4 1
A setBasketId() 0 4 1
A getCustomerId() 0 4 1
A setCustomerId() 0 4 1
A getTypeId() 0 4 1
A setTypeId() 0 4 1
A getEndpoint() 0 4 1
A createResponse() 0 4 1
1
<?php
2
namespace Omnipay\Heidelpay\Message;
3
4
/**
5
 * Payment Request
6
 *
7
 * @method Response send()
8
 */
9
class PaymentRequest extends AbstractRequest
10
{
11
    public function getData()
12
    {
13
        $this->validate('amount', 'currency', 'typeId');
14
15
        $data = [];
16
        $data['amount'] = $this->getAmount();
17
        $data['currency'] = $this->getCurrency();
18
19
        if ($this->getReturnUrl()) {
20
            $data['returnUrl'] = $this->getReturnUrl();
21
        }
22
23
        if ($this->getTransactionId()) {
24
            $data['orderId'] = $this->getTransactionId();
25
        }
26
27
        $data['resources'] = [
28
            'typeId' => $this->getTypeId()
29
        ];
30
31
        if ($this->getCustomerId()) {
32
            $data['resources']['customerId'] = $this->getCustomerId();
33
        }
34
35
        if ($this->getBasketId()) {
36
            $data['resources']['basketId'] = $this->getBasketId();
37
        }
38
39
        if ($this->getMetaDataId()) {
40
            $data['resources']['metadataid'] = $this->getMetaDataId();
41
        }
42
43
        return $data;
44
    }
45
46
    public function getMetaDataId()
47
    {
48
        return $this->getParameter('metadataid');
49
    }
50
51
    public function setMetaDataId($value)
52
    {
53
        return $this->setParameter('metadataid', $value);
54
    }
55
56
    public function getBasketId()
57
    {
58
        return $this->getParameter('basketId');
59
    }
60
61
    public function setBasketId($value)
62
    {
63
        return $this->setParameter('basketId', $value);
64
    }
65
66
    public function getCustomerId()
67
    {
68
        return $this->getParameter('customerId');
69
    }
70
71
    public function setCustomerId($value)
72
    {
73
        return $this->setParameter('customerId', $value);
74
    }
75
76
    public function getTypeId()
77
    {
78
        return $this->getParameter('typeId');
79
    }
80
81
    public function setTypeId($value)
82
    {
83
        return $this->setParameter('typeId', $value);
84
    }
85
86
    public function getEndpoint()
87
    {
88
        return parent::getEndpoint() . 'payments/';
89
    }
90
91
    protected function createResponse($data)
92
    {
93
        return $this->response = new PaymentResponse($this, $data);
94
    }
95
}
96