Completed
Push — main ( 7136de...6d50be )
by Leonard
03:35
created

PurchaseRequest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 0
loc 41
ccs 20
cts 22
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 32 4
A sendData() 0 4 1
1
<?php
2
3
namespace Omnipay\YooMoney\Message;
4
5
class PurchaseRequest extends AbstractRequest
6
{
7
8 6
    public function getData()
9
    {
10 6
        $this->validate('amount', 'description', 'transactionId');
11
12 6
        $targets = $this->getTargets();
13 6
        if (!$targets) {
14 6
            $targets = $this->getDescription();
15
        }
16
17
        $data = [
18 6
            'targets'       => $targets,
19 6
            'receiver'      => $this->getReceiver(),
20 6
            'quickpay-form' => $this->getQuickpayForm(),
21 6
            'paymentType'   => $this->getPaymentType(),
22 6
            'sum'           => $this->getAmount(),
23 6
            'label'         => $this->getTransactionId(),
24 6
            'need-fio'      => $this->getNeedFio(),
25 6
            'need-email'    => $this->getNeedEmail(),
26 6
            'need-phone'    => $this->getNeedPhone(),
27 6
            'need-address'  => $this->getNeedAddress(),
28
        ];
29
30 6
        if ($this->getSuccessUrl()) {
31
            $data['successURL'] = $this->getSuccessUrl();
32
        }
33
34 6
        if ($this->getTargets()) {
35
            $data['comment'] = $this->getDescription();
36
        }
37
38 6
        return $data;
39
    }
40
41 3
    public function sendData($data)
42
    {
43 3
        return $this->response = new PurchaseResponse($this, $data);
44
    }
45
}
46