TokenRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 55
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 9 1
A getCard() 0 3 1
A getTerminalType() 0 3 1
A __construct() 0 4 1
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
}