AbstractRequest   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 23
c 2
b 1
f 0
dl 0
loc 80
ccs 31
cts 31
cp 1
rs 10
wmc 15

13 Methods

Rating   Name   Duplication   Size   Complexity  
A setMerchantKey() 0 3 1
A setPaymentMethod() 0 3 1
A getMerchantKey() 0 3 1
A sendData() 0 15 2
A getHttpMethod() 0 3 1
A getPaymentProfile() 0 3 1
A getOrderNumber() 0 3 1
A getEndpoint() 0 3 2
A setOrderNumber() 0 3 1
A getPaymentMethod() 0 3 1
A setPaymentProfile() 0 3 1
A setMerchantId() 0 3 1
A getMerchantId() 0 3 1
1
<?php
2
3
namespace  Omnipay\Moneris\Message;
4
5
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
6
{
7
    public $testEndpoint = 'https://esqa.moneris.com:443/gateway2/servlet/MpgRequest';
8
    public $liveEndpoint = 'https://www3.moneris.com:443/gateway2/servlet/MpgRequest';
9
10 39
    public function getEndpoint()
11
    {
12 39
        return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
13
    }
14
15 60
    public function getMerchantId()
16
    {
17 60
        return $this->getParameter('merchantId');
18
    }
19
20 78
    public function setMerchantId($value)
21
    {
22 78
        return $this->setParameter('merchantId', $value);
23
    }
24
25 60
    public function getMerchantKey()
26
    {
27 60
        return $this->getParameter('merchantKey');
28
    }
29
30 78
    public function setMerchantKey($value)
31
    {
32 78
        return $this->setParameter('merchantKey', $value);
33
    }
34
35 18
    public function getPaymentMethod()
36
    {
37 18
        return $this->getParameter('paymentMethod');
38
    }
39
40 18
    public function setPaymentMethod($value)
41
    {
42 18
        return $this->setParameter('paymentMethod', $value);
43
    }
44
45 3
    public function getPaymentProfile()
46
    {
47 3
        return $this->getParameter('paymentProfile');
48
    }
49
50 3
    public function setPaymentProfile($value)
51
    {
52 3
        return $this->setParameter('paymentProfile', $value);
53
    }
54
55 15
    public function getOrderNumber()
56
    {
57 15
        return $this->getParameter('orderNumber');
58
    }
59
60 21
    public function setOrderNumber($value)
61
    {
62 21
        return $this->setParameter('orderNumber', $value);
63
    }
64
65 39
    protected function getHttpMethod()
66
    {
67 39
        return 'POST';
68
    }
69
70 39
    public function sendData($data)
71
    {
72
        $headers = [
73 39
            'Content-Type' => 'application/xml',
74
        ];
75
76 39
        $httpResponse = $this->httpClient->request($this->getHttpMethod(), $this->getEndpoint(), $headers, $data);
77
78
        try {
79 39
            $xmlResponse = simplexml_load_string($httpResponse->getBody()->getContents());
80 3
        } catch (\Exception $e) {
81 3
            $xmlResponse = (string) $httpResponse->getBody(true);
0 ignored issues
show
Unused Code introduced by
The call to Psr\Http\Message\MessageInterface::getBody() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
            $xmlResponse = (string) $httpResponse->/** @scrutinizer ignore-call */ getBody(true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
82
        }
83
84 39
        return $this->response = new Response($this, $xmlResponse);
85
    }
86
}
87