Passed
Push — master ( 03a515...f437cc )
by Matt
02:39
created

Configuration::setCertificateVerify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CommerceGuys\AuthNet;
4
5
class Configuration
6
{
7
    private $apiLogin;
8
    private $transactionKey;
9
    private $sandbox;
10
    private $requestMode = 'xml';
11
    private $certificateVerify;
12
13 21
    public function __construct(array $config)
14
    {
15 21
        foreach (['api_login', 'transaction_key', 'sandbox'] as $required_key) {
16 21
            if (!isset($config[$required_key])) {
17
                throw new \InvalidArgumentException("You must provide a value for $required_key");
18
            }
19 21
        }
20 21
        $this->apiLogin = $config['api_login'];
21 21
        $this->transactionKey = $config['transaction_key'];
22 21
        $this->sandbox = $config['sandbox'];
23
24 21
        if (isset($config['request_mode'])) {
25 18
            $this->requestMode = $config['request_mode'];
26 18
        }
27
28 21
        if (isset($config['certificate_verify'])) {
29 18
            $this->certificateVerify = $config['certificate_verify'];
30 18
        } else {
31 3
            $this->certificateVerify = __DIR__ . '/../resources/cert.pem';
32
        }
33 21
    }
34
35
    /**
36
     * @return mixed
37
     */
38 16
    public function getApiLogin()
39
    {
40 16
        return $this->apiLogin;
41
    }
42
43
    /**
44
     * @param mixed $apiLogin
45
     * @return Configuration
46
     */
47 1
    public function setApiLogin($apiLogin)
48
    {
49 1
        $this->apiLogin = $apiLogin;
50 1
        return $this;
51
    }
52
53
    /**
54
     * @return mixed
55
     */
56 16
    public function getTransactionKey()
57
    {
58 16
        return $this->transactionKey;
59
    }
60
61
    /**
62
     * @param mixed $transactionKey
63
     * @return Configuration
64
     */
65 1
    public function setTransactionKey($transactionKey)
66
    {
67 1
        $this->transactionKey = $transactionKey;
68 1
        return $this;
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74 13
    public function getSandbox()
75
    {
76 13
        return $this->sandbox;
77
    }
78
79
    /**
80
     * @param mixed $sandbox
81
     * @return Configuration
82
     */
83 1
    public function setSandbox($sandbox)
84
    {
85 1
        $this->sandbox = $sandbox;
86 1
        return $this;
87
    }
88
89
    /**
90
     * @return mixed|string
91
     */
92 13
    public function getRequestMode()
93
    {
94 13
        return $this->requestMode;
95
    }
96
97
    /**
98
     * @param mixed|string $requestMode
99
     * @return Configuration
100
     */
101 1
    public function setRequestMode($requestMode)
102
    {
103 1
        $this->requestMode = $requestMode;
104 1
        return $this;
105
    }
106
107
    /**
108
     * @return mixed|string
109
     */
110 13
    public function getCertificateVerify()
111
    {
112 13
        return $this->certificateVerify;
113
    }
114
115
    /**
116
     * @param mixed|string $value
117
     * @return Configuration
118
     */
119 1
    public function setCertificateVerify($value)
120
    {
121 1
        $this->certificateVerify = $value;
122 1
        return $this;
123
    }
124
}
125