CreateCardRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 10 1
A getEndpoint() 0 4 1
1
<?php
2
/**
3
 * Ebanx createCard Request.
4
 */
5
namespace Omnipay\Ebanx\Message;
6
7
/**
8
 * Ebanx createCard Request.
9
 *
10
 * The create card request is used to create a token
11
 * for a given credit card to be used for recurrent payments.
12
 *
13
 * Example:
14
 *
15
 * <code>
16
 *   // Initialise the gateway
17
 *   $gateway->initialize(array(
18
 *       'integration_key' => 'MyApiKey',
19
 *   ));
20
 *
21
 *   // Create a credit card object
22
 *   // This card can be used for testing.
23
 *   $card = new CreditCard(array(
24
 *               'firstName'    => 'Example',
25
 *               'lastName'     => 'Customer',
26
 *               'number'       => '4242424242424242',
27
 *               'expiryMonth'  => '01',
28
 *               'expiryYear'   => '2020',
29
 *               'cvv'          => '123',
30
 *               'email'        => '[email protected]',
31
 *               'address1'     => 'Street name, Street number, Complement',
32
 *               'address2'     => 'Neighborhood',
33
 *               'city'         => 'City',
34
 *               'state'        => 'sp',
35
 *               'country'      => 'BR',
36
 *               'postcode'     => '05443100',
37
 *               'phone'        => '19 3242 8855',
38
 *   ));
39
 *
40
 *   // Do an authorize transaction on the gateway
41
 *   $transaction = $gateway->createCard(array(
42
 *       'card'             => $card,
43
 *   ));
44
 *
45
 *   $response = $transaction->send();
46
 *   if ($response->isSuccessful()) {
47
 *       echo $response->getCardReference();
48
 *   }
49
 * </code>
50
 *
51
 * @see  \Omnipay\Ebanx\Gateway
52
 * @link https://developers.ebanxpagamentos.com/api-reference/ebanx-payment-api/payment-reference/reference-token-operation/
53
 */
54
class CreateCardRequest extends AbstractRequest
55
{
56 3
    public function getData()
57
    {
58 3
        $this->validate('card');
59
60 3
        $data                      = array_merge($this->getDefaultParameters(), $this->getCardData());
61 3
        $data['country']           = $this->getCard()->getCountry();
62 3
        $data['payment_type_code'] = $this->getCard()->getBrand();
63
64 3
        return $data;
65
    }
66
67 3
    public function getEndpoint()
68
    {
69 3
        return parent::getEndpoint() . '/token';
70
    }
71
}
72