AmazonGiftCode::make()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 5
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace kamerk22\AmazonGiftCode;
4
5
use kamerk22\AmazonGiftCode\AWS\AWS;
6
use kamerk22\AmazonGiftCode\Config\Config;
7
use kamerk22\AmazonGiftCode\Exceptions\AmazonErrors;
8
9
class AmazonGiftCode
10
{
11
12
    private $_config;
13
14
    /**
15
     * AmazonGiftCode constructor.
16
     *
17
     * @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...
18
     * @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...
19
     * @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...
20
     * @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...
21
     * @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...
22
     */
23
    public function __construct($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null)
24
    {
25
        $this->_config = new Config($key, $secret, $partner, $endpoint, $currency);
26
    }
27
28
    /**
29
     * @param Float $value
30
     * @param string $creationRequestId
31
     * @return Response\CreateResponse
32
     *
33
     * @throws AmazonErrors
34
     */
35
    public function buyGiftCard(Float $value, string $creationRequestId = null): Response\CreateResponse
36
    {
37
        return (new AWS($this->_config))->getCode($value, $creationRequestId);
38
    }
39
40
41
    /**
42
     * @param string $creationRequestId
43
     * @param string $gcId
44
     * @return Response\CancelResponse
45
     */
46
    public function cancelGiftCard(string $creationRequestId, string $gcId): Response\CancelResponse
47
    {
48
        return (new AWS($this->_config))->cancelCode($creationRequestId, $gcId);
49
    }
50
51
    /**
52
     * @return Response\CreateBalanceResponse
53
     *
54
     * @throws AmazonErrors
55
     */
56
    public function getAvailableFunds(): Response\CreateBalanceResponse
57
    {
58
        return (new AWS($this->_config))->getBalance();
59
    }
60
61
    /**
62
     * AmazonGiftCode make own client.
63
     *
64
     * @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...
65
     * @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...
66
     * @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...
67
     * @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...
68
     * @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...
69
     * @return AmazonGiftCode
70
     */
71
    public static function make($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null): AmazonGiftCode
72
    {
73
        return new static($key, $secret, $partner, $endpoint, $currency);
74
    }
75
76
}
77