CreateCardRequest::getData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 6
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 CreateCardRequest extends AbstractPaypalRequest
11
{
12
    /**
13
     * @return string
14
     */
15
    public function getEndpoint()
16
    {
17
        return '/vault/credit-card';
18
    }
19
20
    /**
21
     * @return string
22
     */
23
    public function getHttpMethod()
24
    {
25
        return 'POST';
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getPayerId()
32
    {
33
        return $this->getParameter('payerId');
34
    }
35
36
    /**
37
     * @param string $value
38
     */
39
    public function setPayerId($value)
40
    {
41
        return $this->setParameter('payerId', $value);
42
    }
43
    /**
44
     * @param  mixed              $data
45
     * @return CreateCardResponse
46
     */
47
    public function sendData($data)
48
    {
49
        $httpResponse = $this->sendHttpRequest($data);
50
51
        return $this->response = new CreateCardResponse(
52
            $this,
53
            $httpResponse->json(),
54
            $httpResponse->getStatusCode()
55
        );
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getData()
62
    {
63
        $data = $this->getPaypalCard();
64
65
        if ($this->getPayerId()) {
66
            $data['payer_id'] = $this->getPayerId();
67
        }
68
69
        return $data;
70
    }
71
}
72