TokenRequest::getCard()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: WilliamWard
5
 * Date: 8/6/2018
6
 * Time: 3:35 PM
7
 */
8
9
namespace GivePay\Gateway\Transactions;
10
11
final class TokenRequest
12
{
13
    /**
14
     * @var Card card
15
     */
16
    private $card;
17
18
    /**
19
     * @var string Terminal Type
20
     */
21
    private $terminal_type;
22
23
    /**
24
     * TokenRequest constructor.
25
     * @param Card $card
26
     * @param string $terminal_type
27
     */
28 2
    public function __construct($card, $terminal_type)
29
    {
30 2
        $this->card = $card;
31 2
        $this->terminal_type = $terminal_type;
32 2
    }
33
34
    /**
35
     * Serializes the tokenization request into a GPG request
36
     * @param string $merchant_id
37
     * @param string $terminal_id
38
     * @return array
39
     */
40 1
    public function serialize($merchant_id, $terminal_id)
41
    {
42
        return array(
43 1
            'mid' => $merchant_id,
44
            'terminal' => array(
45 1
                'tid' => $terminal_id,
46 1
                'terminal_type' => $this->getTerminalType()
47
            ),
48 1
            'card' => $this->getCard()->serialize()
49
        );
50
    }
51
52
    /**
53
     * @return string
54
     */
55 1
    public function getTerminalType()
56
    {
57 1
        return $this->terminal_type;
58
    }
59
60
    /**
61
     * @return \GivePay\Gateway\Transactions\Card
62
     */
63 1
    public function getCard()
64
    {
65 1
        return $this->card;
66
    }
67
}