Passed
Pull Request — master (#43)
by
unknown
01:50
created

getMerchantAuthentication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace CommerceGuys\AuthNet;
4
5
use CommerceGuys\AuthNet\DataTypes\MerchantAuthentication;
6
use CommerceGuys\AuthNet\Request\RequestInterface;
7
8
/**
9
 * Represents the authenticateTestRequest endpoint for testing API credentials.
10
 *
11
 * This request verifies that the provided API Login ID and Transaction Key
12
 * are valid and that the merchant is authorized to submit transactions.
13
 *
14
 * Commonly used to validate configuration forms or connectivity.
15
 *
16
 * @link https://developer.authorize.net/api/reference/index.html#gettingstarted-section-section-header
17
 */
18
class AuthenticateTestRequest extends BaseApiRequest
19
{
20
21
    /**
22
     * Sets the merchant authentication credentials.
23
     *
24
     * @param \CommerceGuys\AuthNet\DataTypes\MerchantAuthentication $merchantAuthentication
25
     *
26
     * @return $this
27
     */
28
    public function setMerchantAuthentication(MerchantAuthentication $merchantAuthentication): self
29
    {
30
        $this->merchantAuthentication = $merchantAuthentication;
31
        return $this;
32
    }
33
34
    /**
35
     * Gets the merchant authentication credentials.
36
     *
37
     * @return \CommerceGuys\AuthNet\DataTypes\MerchantAuthentication|null
38
     */
39
    public function getMerchantAuthentication(): ?MerchantAuthentication
40
    {
41
        return $this->merchantAuthentication;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function attachData(RequestInterface $request): void
48
    {
49
        // Only attach merchant authentication if available.
50
        if ($this->merchantAuthentication) {
51
            $request->addDataType($this->merchantAuthentication);
52
        }
53
    }
54
}
55