Product::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\Product as ProductContract;
4
use Arcanedev\Stripe\StripeResource;
5
6
/**
7
 * Class     Product
8
 *
9
 * @package  Arcanedev\Stripe\Resources
10
 * @author   ARCANEDEV <[email protected]>
11
 * @link     https://stripe.com/docs/api/php#product_object
12
 *
13
 * @property  string                            id
14
 * @property  string                            object       // 'product'
15
 * @property  bool                              active
16
 * @property  array                             attributes
17
 * @property  string                            caption
18
 * @property  int                               created      // timestamp
19
 * @property  array                             deactivate_on
20
 * @property  string                            description
21
 * @property  array                             images
22
 * @property  bool                              livemode
23
 * @property  \Arcanedev\Stripe\AttachedObject  metadata
24
 * @property  string                            name
25
 * @property  array|null                        package_dimensions
26
 * @property  bool                              shippable
27
 * @property  \Arcanedev\Stripe\Collection      skus
28
 * @property  int                               updated
29
 * @property  string                            url
30
 */
31
class Product extends StripeResource implements ProductContract
32
{
33
    /* ------------------------------------------------------------------------------------------------
34
     |  Main Functions
35
     | ------------------------------------------------------------------------------------------------
36
     */
37
    /**
38
     * List all Products.
39
     * @link   https://stripe.com/docs/api/php#list_products
40
     *
41
     * @param  array|null         $params
42
     * @param  array|string|null  $options
43
     *
44
     * @return \Arcanedev\Stripe\Collection|array
45
     */
46 2
    public static function all($params = [], $options = null)
47
    {
48 2
        return self::scopedAll($params, $options);
49
    }
50
51
    /**
52
     * Retrieve a product.
53
     * @link   https://stripe.com/docs/api/php#retrieve_product
54
     *
55
     * @param  string             $id
56
     * @param  array|string|null  $options
57
     *
58
     * @return self
59
     */
60 4
    public static function retrieve($id, $options = null)
61
    {
62 4
        return self::scopedRetrieve($id, $options);
63
    }
64
65
    /**
66
     * Create a Product.
67
     * @link   https://stripe.com/docs/api/php#create_product
68
     *
69
     * @param  array|null         $params
70
     * @param  array|string|null  $options
71
     *
72
     * @return self
73
     */
74 34
    public static function create($params = [], $options = null)
75
    {
76 34
        return self::scopedCreate($params, $options);
77
    }
78
79
    /**
80
     * Update a Product.
81
     * @link   https://stripe.com/docs/api/php#update_product
82
     *
83
     * @param  string             $id
84
     * @param  array|null         $params
85
     * @param  array|string|null  $options
86
     *
87
     * @return self
88
     */
89 2
    public static function update($id, $params = [], $options = null)
90
    {
91 2
        return self::scopedUpdate($id, $params, $options);
92
    }
93
94
    /**
95
     * Update/Save a Product.
96
     * @link   https://stripe.com/docs/api/php#update_product
97
     *
98
     * @param  array|string|null  $options
99
     *
100
     * @return self
101
     */
102 2
    public function save($options = null)
103
    {
104 2
        return $this->scopedSave($options);
105
    }
106
107
    /**
108
     * Delete a Product.
109
     * @link   https://stripe.com/docs/api/php#delete_product
110
     *
111
     * @param  array|null         $params
112
     * @param  array|string|null  $options
113
     *
114
     * @return self
115
     */
116 2
    public function delete($params = [], $options = null)
117
    {
118 2
        return $this->scopedDelete($params, $options);
119
    }
120
}
121