Passed
Push — master ( 3eda92...6eac5c )
by Unoapp
07:15 queued 10s
created

AbstractRequest::setCryptType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 45
    public function getEndpoint()
11
    {
12 45
        return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
13
    }
14
15 69
    public function getMerchantId()
16
    {
17 69
        return $this->getParameter('merchantId');
18
    }
19
20 90
    public function setMerchantId($value)
21
    {
22 90
        return $this->setParameter('merchantId', $value);
23
    }
24
25 69
    public function getMerchantKey()
26
    {
27 69
        return $this->getParameter('merchantKey');
28
    }
29
30 90
    public function setMerchantKey($value)
31
    {
32 90
        return $this->setParameter('merchantKey', $value);
33
    }
34
35 63
    public function getCryptType()
36
    {
37 63
        return $this->getParameter('cryptType');
38
    }
39
40 90
    public function setCryptType($value)
41
    {
42 90
        return $this->setParameter('cryptType', $value);
43
    }
44
45 18
    public function getPaymentMethod()
46
    {
47 18
        return $this->getParameter('paymentMethod');
48
    }
49
50 18
    public function setPaymentMethod($value)
51
    {
52 18
        return $this->setParameter('paymentMethod', $value);
53
    }
54
55 3
    public function getPaymentProfile()
56
    {
57 3
        return $this->getParameter('paymentProfile');
58
    }
59
60 3
    public function setPaymentProfile($value)
61
    {
62 3
        return $this->setParameter('paymentProfile', $value);
63
    }
64
65 15
    public function getOrderNumber()
66
    {
67 15
        return $this->getParameter('orderNumber');
68
    }
69
70 21
    public function setOrderNumber($value)
71
    {
72 21
        return $this->setParameter('orderNumber', $value);
73
    }
74
75 45
    protected function getHttpMethod()
76
    {
77 45
        return 'POST';
78
    }
79
80 45
    public function sendData($data)
81
    {
82
        $headers = [
83 45
            'Content-Type' => 'application/xml',
84
        ];
85
86 45
        $httpResponse = $this->httpClient->request($this->getHttpMethod(), $this->getEndpoint(), $headers, $data);
87
88
        try {
89 45
            $xmlResponse = simplexml_load_string($httpResponse->getBody()->getContents());
90 3
        } catch (\Exception $e) {
91 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

91
            $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...
92
        }
93
94 45
        return $this->response = new Response($this, $xmlResponse);
95
    }
96
}
97