AbstractRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 44
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getServer() 0 4 2
B getPaypalCard() 0 25 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
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
11
{
12
    const LIVE = 'https://api.paypal.com/v1';
13
    const SANDBOX = 'https://api.sandbox.paypal.com/v1';
14
15
    /**
16
     * @return string
17
     */
18
    public function getServer()
19
    {
20
        return $this->getTestMode() ? self::SANDBOX : self::LIVE;
21
    }
22
23
    /**
24
     * Requires a valid "card" parameter
25
     *
26
     * @return array
27
     */
28
    public function getPaypalCard()
29
    {
30
        $this->validate('card');
31
32
        $card = $this->getCard();
33
        $card->validate();
34
35
        return array_filter(array(
36
            'number' => $card->getNumber(),
37
            'type' => $card->getBrand(),
38
            'expire_month' => $card->getExpiryMonth(),
39
            'expire_year' => $card->getExpiryYear(),
40
            'cvv2' => $card->getCvv(),
41
            'first_name' => $card->getFirstName(),
42
            'last_name' => $card->getLastName(),
43
            'billing_address' => array_filter(array(
44
                'line1' => $card->getAddress1(),
45
                'line2' => $card->getAddress2(),
46
                'city' => $card->getCity(),
47
                'state' => $card->getState(),
48
                'postal_code' => $card->getPostcode(),
49
                'country_code' => strtoupper($card->getCountry()),
50
            ))
51
        ));
52
    }
53
}
54