Passed
Pull Request — master (#7)
by
unknown
10:39 queued 07:49
created

AmazonGiftCode::make()   A

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
     * @return Response\CreateResponse
31
     *
32
     * @throws AmazonErrors
33
     */
34
    public function buyGiftCard(Float $value): Response\CreateResponse
35
    {
36
        return (new AWS($this->_config))->getCode($value);
37
    }
38
39
40
    /**
41
     * @param string $creationRequestId
42
     * @param string $gcId
43
     * @return Response\CancelResponse
44
     */
45
    public function cancelGiftCard(string $creationRequestId, string $gcId): Response\CancelResponse
46
    {
47
        return (new AWS($this->_config))->cancelCode($creationRequestId, $gcId);
48
    }
49
50
    /**
51
     * @return Response\CreateBalanceResponse
52
     *
53
     * @throws AmazonErrors
54
     */
55
    public function getAvailableFunds(): Response\CreateBalanceResponse
56
    {
57
        return (new AWS($this->_config))->getBalance();
58
    }
59
60
    /**
61
     * AmazonGiftCode make own client.
62
     *
63
     * @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...
64
     * @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...
65
     * @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...
66
     * @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...
67
     * @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...
68
     * @return AmazonGiftCode
69
     */
70
    public static function make($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null): AmazonGiftCode
71
    {
72
        return new static($key, $secret, $partner, $endpoint, $currency);
73
    }
74
75
}