Completed
Push — master ( 0f907a...866d23 )
by Andrii
02:30
created

CompletePurchaseRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 2
c 4
b 1
f 0
lcom 2
cbo 6
dl 0
loc 36
ccs 15
cts 15
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 8 1
A sendData() 0 15 1
1
<?php
2
3
/*
4
 * PayPal driver for Omnipay PHP payment library
5
 *
6
 * @link      https://github.com/hiqdev/omnipay-paypal
7
 * @package   omnipay-paypal
8
 * @license   MIT
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace Omnipay\PayPal\Message;
13
14
/**
15
 * PayPal Complete Purchase Request.
16
 */
17
class CompletePurchaseRequest extends AbstractRequest
18
{
19
    /**
20
     * Get the data for this request.
21
     * @return array request data
22
     */
23 2
    public function getData()
24
    {
25 2
        $this->validate('purse');
26
27 2
        return array_merge([
28 2
            'cmd' => '_notify-validate',
29 2
        ], $this->httpRequest->request->all());
30
    }
31
32
    /**
33
     * Send the request with specified data.
34
     * @param mixed $data The data to send
35
     * @return CompletePurchaseResponse
36
     */
37 1
    public function sendData($data)
38
    {
39 1
        $this->httpClient->setConfig([
40
            'curl.options' => [
41 1
                CURLOPT_SSLVERSION => 1,
42 1
                CURLOPT_SSL_VERIFYHOST => 2,
43 1
                CURLOPT_SSL_VERIFYPEER => 1,
44 1
            ],
45 1
        ]);
46
47 1
        $httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send();
48 1
        $data['_result'] = $httpResponse->getBody(1);
49
50 1
        return $this->response = new CompletePurchaseResponse($this, $data);
51
    }
52
}
53