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

Account   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 129
ccs 20
cts 22
cp 0.9091
rs 10
c 1
b 0
f 0
wmc 12
lcom 0
cbo 1

8 Methods

Rating   Name   Duplication   Size   Complexity  
A instanceUrl() 0 4 2
A all() 0 4 1
A update() 0 4 1
A save() 0 4 1
A delete() 0 4 1
A retrieve() 0 13 4
A create() 0 4 1
A reject() 0 6 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\Account as AccountContract;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Account
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#account_object
12
 *
13
 * @property  null                              id
14
 * @property  string                            object                   // 'account'
15
 * @property  string|null                       business_logo
16
 * @property  string                            business_name
17
 * @property  string|null                       business_url
18
 * @property  bool                              charges_enabled
19
 * @property  string                            country
20
 * @property  bool                              debit_negative_balances  // managed accounts only
21
 * @property  \Arcanedev\Stripe\StripeObject    decline_charge_on
22
 * @property  string                            default_currency
23
 * @property  bool                              details_submitted
24
 * @property  string                            display_name
25
 * @property  string                            email
26
 * @property  \Arcanedev\Stripe\Collection      external_accounts        // managed accounts only
27
 * @property  \Arcanedev\Stripe\AttachedObject  legal_entity             // managed accounts only
28
 * @property  \Arcanedev\Stripe\Collection      login_links
29
 * @property  bool                              managed
30
 * @property  mixed                             payout_schedule
31
 * @property  mixed                             payout_statement_descriptor
32
 * @property  bool                              payouts_enabled
33
 * @property  string|null                       product_description      // managed accounts only
34
 * @property  string|null                       statement_descriptor
35
 * @property  string|null                       support_email
36
 * @property  string|null                       support_phone
37
 * @property  string|null                       support_url
38
 * @property  string                            timezone
39
 * @property  \Arcanedev\Stripe\AttachedObject  tos_acceptance           // managed accounts only
40
 * @property  \Arcanedev\Stripe\AttachedObject  transfer_schedule        // managed accounts only
41
 * @property  bool                              transfers_enabled
42
 * @property  \Arcanedev\Stripe\AttachedObject  verification
43
 */
44
class Account extends StripeResource implements AccountContract
45
{
46
    /* ------------------------------------------------------------------------------------------------
47
     |  Getters & Setters
48
     | ------------------------------------------------------------------------------------------------
49
     */
50
    /**
51
     * Get the instance url.
52
     *
53
     * @return string
54
     */
55 18
    public function instanceUrl()
56
    {
57 18
        return is_null($this['id']) ? '/v1/account' : parent::instanceUrl();
58
    }
59
60
    /* ------------------------------------------------------------------------------------------------
61
     |  Main Functions
62
     | ------------------------------------------------------------------------------------------------
63
     */
64
    /**
65
     * Get all Accounts.
66
     * @link   https://stripe.com/docs/api/php#list_accounts
67
     *
68
     * @param  array|null         $params
69
     * @param  array|string|null  $options
70
     *
71
     * @return \Arcanedev\Stripe\Collection|array
72
     */
73 2
    public static function all($params = [], $options = null)
74
    {
75 2
        return self::scopedAll($params, $options);
76
    }
77
78
    /**
79
     * Retrieve an Account.
80
     * @link   https://stripe.com/docs/api/php#retrieve_account
81
     *
82
     * @param  string|null        $id
83
     * @param  array|string|null  $options
84
     *
85
     * @return self
86
     */
87 10
    public static function retrieve($id = null, $options = null)
88
    {
89
        if (
90 10
            ! $options &&
91 10
            is_string($id) &&
92 10
            substr($id, 0, 3) === 'sk_'
93
        ) {
94
            $options = $id;
95
            $id      = null;
96
        }
97
98 10
        return self::scopedRetrieve($id, $options);
99
    }
100
101
    /**
102
     * Create an Account.
103
     * @link   https://stripe.com/docs/api/php#create_account
104
     *
105
     * @param  array|null         $params
106
     * @param  array|string|null  $options
107
     *
108
     * @return self
109
     */
110 22
    public static function create($params = [], $options = null)
111
    {
112 22
        return self::scopedCreate($params, $options);
113
    }
114
115
    /**
116
     * Update an Account.
117
     * @link   https://stripe.com/docs/api/php#update_account
118
     *
119
     * @param  string             $id
120
     * @param  array|null         $params
121
     * @param  array|string|null  $options
122
     *
123
     * @return self
124
     */
125 2
    public static function update($id, $params = [], $options = null)
126
    {
127 2
        return self::scopedUpdate($id, $params, $options);
128
    }
129
130
    /**
131
     * Update/Save an Account.
132
     * @link   https://stripe.com/docs/api/php#update_account
133
     *
134
     * @param  array|string|null  $options
135
     *
136
     * @return self
137
     */
138 4
    public function save($options = null)
139
    {
140 4
        return $this->scopedSave($options);
141
    }
142
143
    /**
144
     * Delete an Account.
145
     * @link   https://stripe.com/docs/api/php#delete_account
146
     *
147
     * @param  array|null         $params
148
     * @param  array|string|null  $options
149
     *
150
     * @return self
151
     */
152 2
    public function delete($params = [], $options = null)
153
    {
154 2
        return $this->scopedDelete($params, $options);
155
    }
156
157
    /**
158
     * Reject an Account.
159
     * @link   https://stripe.com/docs/api/php#reject_account
160
     *
161
     * @param  array|null         $params
162
     * @param  array|string|null  $options
163
     *
164
     * @return self
165
     */
166 2
    public function reject($params = [], $options = null)
167
    {
168 2
        return $this->scopedPostCall(
169 2
            $this->instanceUrl() . '/reject', $params, $options
170
        );
171
    }
172
}
173