Completed
Push — master ( 27c102...e85ee7 )
by Haralan
03:23 queued 01:27
created

PaymentCompleteRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 3
dl 0
loc 63
ccs 0
cts 33
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getEndpoint() 0 6 1
A getHttpMethod() 0 4 1
A getPayerId() 0 4 1
A setPayerId() 0 4 1
A sendData() 0 10 1
A getData() 0 8 1
1
<?php
2
3
namespace Omnipay\PaypalRest\Message;
4
5
/**
6
 * @author    Ivan Kerin <[email protected]>
7
 * @copyright 2014, Clippings Ltd.
8
 * @license   http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class PaymentCompleteRequest extends AbstractPaypalRequest
11
{
12
    /**
13
     * @return string
14
     */
15
    public function getEndpoint()
16
    {
17
        $this->validate('transactionReference');
18
19
        return "/payments/payment/{$this->getTransactionReference()}/execute";
20
    }
21
22
    /**
23
     * @return string
24
     */
25
    public function getHttpMethod()
26
    {
27
        return 'POST';
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getPayerId()
34
    {
35
        return $this->getParameter('payerId');
36
    }
37
38
    /**
39
     * @param string $value
40
     */
41
    public function setPayerId($value)
42
    {
43
        return $this->setParameter('payerId', $value);
44
    }
45
46
    /**
47
     * @param  mixed           $data
48
     * @return PaymentResponse
49
     */
50
    public function sendData($data)
51
    {
52
        $httpResponse = $this->sendHttpRequest($data);
53
54
        return $this->response = new PaymentResponse(
55
            $this,
56
            $httpResponse->json(),
57
            $httpResponse->getStatusCode()
58
        );
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function getData()
65
    {
66
        $this->validate('payerId');
67
68
        return array(
69
            'payer_id' => $this->getPayerId(),
70
        );
71
    }
72
}
73