Completed
Pull Request — master (#60)
by ARCANEDEV
08:31
created

ApplicationFeeRefund   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
dl 0
loc 60
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 4 1
A instanceUrl() 0 11 1
A checkId() 0 7 2
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\ApplicationFeeRefund as ApplicationFeeRefundContract;
4
use Arcanedev\Stripe\Exceptions\InvalidRequestException;
5
use Arcanedev\Stripe\StripeResource;
6
7
/**
8
 * Class     ApplicationFeeRefund
9
 *
10
 * @package  Arcanedev\Stripe\Resources
11
 * @author   ARCANEDEV <[email protected]>
12
 * @link     https://stripe.com/docs/api/php#fee_refunds
13
 *
14
 * @property  string                            id
15
 * @property  string                            object                // "fee_refund"
16
 * @property  int                               amount
17
 * @property  string                            balance_transaction
18
 * @property  int                               created
19
 * @property  string                            currency
20
 * @property  string                            fee
21
 * @property  \Arcanedev\Stripe\AttachedObject  metadata
22
 */
23
class ApplicationFeeRefund extends StripeResource implements ApplicationFeeRefundContract
24
{
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Getters & Setters
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Get instance URL - The API URL for this Stripe refund.
31
     *
32
     * @return string
33
     */
34 4
    public function instanceUrl()
35
    {
36 4
        $this->checkId($this['id']);
37
38 2
        return implode('/', [
39 2
            self::classUrl(ApplicationFee::class),
40 2
            urlencode(str_utf8($this['fee'])),
41 2
            'refunds',
42 2
            urlencode(str_utf8($this['id']))
43
        ]);
44
    }
45
46
    /* ------------------------------------------------------------------------------------------------
47
     |  Main Functions
48
     | ------------------------------------------------------------------------------------------------
49
     */
50
    /**
51
     * Update/Save an Application Fee Refund.
52
     *
53
     * @link   https://stripe.com/docs/api/php#update_fee_refund
54
     *
55
     * @param  array|string|null  $options
56
     *
57
     * @return self
58
     */
59
    public function save($options = null)
60
    {
61
        return self::scopedSave($options);
62
    }
63
64
    /* ------------------------------------------------------------------------------------------------
65
     |  Check Functions
66
     | ------------------------------------------------------------------------------------------------
67
     */
68
    /**
69
     * Check if id is not empty.
70
     *
71
     * @param  string  $id
72
     *
73
     * @throws \Arcanedev\Stripe\Exceptions\InvalidRequestException
74
     */
75 4
    protected function checkId($id)
76
    {
77 4
        if ( ! $id)
78 2
            throw new InvalidRequestException(
79 2
                "Could not determine which URL to request: class instance has invalid ID: {$id}", 400
80
            );
81 2
    }
82
}
83