Completed
Push — main ( 9e586c...e73d1c )
by Leonard
03:31
created

PurchaseRequest::getData()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 4.016

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 18
cts 20
cp 0.9
rs 9.408
c 0
b 0
f 0
cc 4
nc 8
nop 0
crap 4.016
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