Completed
Push — master ( 8bbda0...ede634 )
by ARCANEDEV
8s
created

Recipient   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 25%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 123
ccs 4
cts 16
cp 0.25
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A create() 0 4 1
A retrieve() 0 4 1
A save() 0 4 1
A delete() 0 4 1
A transfers() 0 6 1
A addRecipientParam() 0 4 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\RecipientInterface;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Recipient
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#recipient_object
12
 *
13
 * @property  string                            id
14
 * @property  string                            object            // "recipient"
15
 * @property  bool                              livemode
16
 * @property  int                               created
17
 * @property  string                            type
18
 * @property  Object                            active_account
19
 * @property  string                            description
20
 * @property  string                            email
21
 * @property  \Arcanedev\Stripe\AttachedObject  metadata
22
 * @property  string                            name
23
 * @property  \Arcanedev\Stripe\Collection      cards
24
 * @property  string                            default_card
25
 *
26
 * @todo:     Update the properties.
27
 */
28
class Recipient extends StripeResource implements RecipientInterface
29
{
30
    /* ------------------------------------------------------------------------------------------------
31
     |  Properties
32
     | ------------------------------------------------------------------------------------------------
33
     */
34
    /**
35
     * Allow to check attributes while setting
36
     *
37
     * @var bool
38
     */
39
    protected $checkUnsavedAttributes = true;
40
41
    /* ------------------------------------------------------------------------------------------------
42
     |  CRUD Functions
43
     | ------------------------------------------------------------------------------------------------
44
     */
45
    /**
46
     * Retrieve a Recipient.
47
     *
48
     * @link   https://stripe.com/docs/api/php#retrieve_recipient
49
     *
50
     * @param  string             $id
51
     * @param  array|string|null  $options
52
     *
53
     * @return self
54
     */
55
    public static function retrieve($id, $options = null)
56
    {
57
        return self::scopedRetrieve($id, $options);
58
    }
59
60
    /**
61
     * List all Recipients.
62
     *
63
     * @link   https://stripe.com/docs/api/php#list_recipients
64
     *
65
     * @param  array|null         $params
66
     * @param  array|string|null  $options
67
     *
68
     * @return \Arcanedev\Stripe\Collection|array
69
     */
70 5
    public static function all($params = [], $options = null)
71
    {
72 5
        return self::scopedAll($params, $options);
73
    }
74
75
    /**
76
     * Create a New Recipient.
77
     *
78
     * @link   https://stripe.com/docs/api/php#create_recipient
79
     *
80
     * @param  array|null         $params
81
     * @param  array|string|null  $options
82
     *
83
     * @return self|array
84
     */
85 65
    public static function create($params = [], $options = null)
86
    {
87 65
        return self::scopedCreate($params, $options);
88
    }
89
90
    /**
91
     * Update/Save a recipient.
92
     *
93
     * @link   https://stripe.com/docs/api/php#update_recipient
94
     *
95
     * @param  array|string|null  $options
96
     *
97
     * @return self
98
     */
99
    public function save($options = null)
100
    {
101
        return self::scopedSave($options);
102
    }
103
104
    /**
105
     * Delete a Recipient.
106
     *
107
     * @link   https://stripe.com/docs/api/php#delete_recipient
108
     *
109
     * @param  array|null         $params
110
     * @param  array|string|null  $options
111
     *
112
     * @return self
113
     */
114
    public function delete($params = [], $options = null)
115
    {
116
        return self::scopedDelete($params, $options);
117
    }
118
119
    /* ------------------------------------------------------------------------------------------------
120
     |  Relationships Functions
121
     | ------------------------------------------------------------------------------------------------
122
     */
123
    /**
124
     * List all recipient's Transfers.
125
     *
126
     * @param  array  $params
127
     *
128
     * @return \Arcanedev\Stripe\Collection|array
129
     */
130
    public function transfers($params = [])
131
    {
132
        $this->addRecipientParam($params);
133
134
        return Transfer::all($params, $this->opts);
135
    }
136
137
    /* ------------------------------------------------------------------------------------------------
138
     |  Other Functions
139
     | ------------------------------------------------------------------------------------------------
140
     */
141
    /**
142
     * Add Recipient ID to Parameters.
143
     *
144
     * @param  array  $params
145
     */
146
    private function addRecipientParam(&$params)
147
    {
148
        $params['recipient'] = $this->id;
149
    }
150
}
151