Passed
Pull Request — master (#13)
by
unknown
03:33
created

AmazonGiftCode::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace kamerk22\AmazonGiftCode;
4
5
use kamerk22\AmazonGiftCode\AWS\AWS;
6
use kamerk22\AmazonGiftCode\Config\Config;
7
use kamerk22\AmazonGiftCode\Config\ConfigInterface;
8
use kamerk22\AmazonGiftCode\Exceptions\AmazonErrors;
9
10
class AmazonGiftCode
11
{
12
13
    private $_config;
14
15
    /**
16
     * AmazonGiftCode constructor.
17
     *
18
     * @param null $key
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $key is correct as it would always require null to be passed?
Loading history...
19
     * @param null $secret
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $secret is correct as it would always require null to be passed?
Loading history...
20
     * @param null $partner
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $partner is correct as it would always require null to be passed?
Loading history...
21
     * @param null $endpoint
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $endpoint is correct as it would always require null to be passed?
Loading history...
22
     * @param null $currency
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $currency is correct as it would always require null to be passed?
Loading history...
23
     */
24
    public function __construct($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null)
25
    {
26
        $this->_config = new Config($key, $secret, $partner, $endpoint, $currency);
27
    }
28
29
    /**
30
     * @return ConfigInterface
31
     */
32
    public function getConfig(): ConfigInterface
33
    {
34
        return $this->_config;
35
    }
36
37
    /**
38
     * @param Float $value
39
     * @param string $creationRequestId
40
     * @return Response\CreateResponse
41
     *
42
     * @throws AmazonErrors
43
     */
44
    public function buyGiftCard(Float $value, string $creationRequestId = null): Response\CreateResponse
45
    {
46
        return (new AWS($this->_config))->getCode($value, $creationRequestId);
47
    }
48
49
50
    /**
51
     * @param string $creationRequestId
52
     * @param string $gcId
53
     * @return Response\CancelResponse
54
     */
55
    public function cancelGiftCard(string $creationRequestId, string $gcId): Response\CancelResponse
56
    {
57
        return (new AWS($this->_config))->cancelCode($creationRequestId, $gcId);
58
    }
59
60
    /**
61
     * @return Response\CreateBalanceResponse
62
     *
63
     * @throws AmazonErrors
64
     */
65
    public function getAvailableFunds(): Response\CreateBalanceResponse
66
    {
67
        return (new AWS($this->_config))->getBalance();
68
    }
69
70
    /**
71
     * AmazonGiftCode make own client.
72
     *
73
     * @param null $key
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $key is correct as it would always require null to be passed?
Loading history...
74
     * @param null $secret
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $secret is correct as it would always require null to be passed?
Loading history...
75
     * @param null $partner
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $partner is correct as it would always require null to be passed?
Loading history...
76
     * @param null $endpoint
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $endpoint is correct as it would always require null to be passed?
Loading history...
77
     * @param null $currency
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $currency is correct as it would always require null to be passed?
Loading history...
78
     * @return AmazonGiftCode
79
     */
80
    public static function make($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null): AmazonGiftCode
81
    {
82
        return new static($key, $secret, $partner, $endpoint, $currency);
83
    }
84
85
}
86