AuthorizeRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 22
c 2
b 0
f 1
dl 0
loc 36
ccs 19
cts 19
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getData() 0 34 2
1
<?php
2
3
namespace Omnipay\Moneris\Message;
4
5
use Omnipay\Common\Exception\InvalidRequestException;
6
7
class AuthorizeRequest extends AbstractRequest
8
{
9 9
    public function getData()
10
    {
11 9
        $data = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $data is dead and can be removed.
Loading history...
12
13 9
        $this->validate('orderNumber', 'amount', 'paymentMethod');
14
15 9
        $paymentMethod = $this->getPaymentMethod();
16
17
        switch ($paymentMethod) {
18 9
            case 'payment_profile':
19 6
                $this->validate('cardReference');
20
21 6
                $request = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><request></request>');
22 6
                $request->addChild('store_id', $this->getMerchantId());
23 6
                $request->addChild('api_token', $this->getMerchantKey());
24
25 6
                $res_purchase_cc = $request->addChild('res_preauth_cc');
26 6
                $res_purchase_cc->addChild('data_key', $this->getCardReference());
27 6
                $res_purchase_cc->addChild('order_id', $this->getOrderNumber());
28 6
                $res_purchase_cc->addChild('cust_id', 'Transaction_'.$this->getOrderNumber());
29 6
                $res_purchase_cc->addChild('amount', $this->getAmount());
30 6
                $res_purchase_cc->addChild('crypt_type', $this->getCryptType());
31
32 6
                $data = $request->asXML();
33 6
                break;
34
35
            // Todo: card & token payment
36
37
            default:
38 3
                throw new InvalidRequestException('Invalid payment method');
39
                break;
40
        }
41
42 6
        return preg_replace('/\n/', '', $data);
43
    }
44
}
45