Completed
Pull Request — master (#18)
by ARCANEDEV
07:31
created

Product   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 75
wmc 5
lcom 0
cbo 1
ccs 8
cts 10
cp 0.8
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A save() 0 4 1
A retrieve() 0 4 1
A create() 0 4 1
A all() 0 4 1
A delete() 0 4 1
1
<?php namespace Arcanedev\Stripe\Resources;
2
3
use Arcanedev\Stripe\Contracts\Resources\ProductInterface;
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 ProductInterface
32
{
33
    /* ------------------------------------------------------------------------------------------------
34
     |  Main Functions
35
     | ------------------------------------------------------------------------------------------------
36
     */
37
    /**
38
     * Retrieve a product.
39
     * @link   https://stripe.com/docs/api/php#retrieve_product
40
     *
41
     * @param  string             $id
42
     * @param  array|string|null  $options
43
     *
44
     * @return self
45
     */
46 10
    public static function retrieve($id, $options = null)
47
    {
48 10
        return self::scopedRetrieve($id, $options);
49
    }
50
51
    /**
52
     * Create a Product.
53
     * @link   https://stripe.com/docs/api/php#create_product
54
     *
55
     * @param  array|null         $params
56
     * @param  array|string|null  $options
57
     *
58
     * @return self
59
     */
60 55
    public static function create($params = null, $options = null)
61
    {
62 55
        return self::scopedCreate($params, $options);
63
    }
64
65
    /**
66
     * Update a Product.
67
     * @link   https://stripe.com/docs/api/php#update_product
68
     *
69
     * @param  array|string|null  $options
70
     *
71
     * @return self
72
     */
73 5
    public function save($options = null)
74
    {
75 5
        return $this->scopedSave($options);
76
    }
77
78
    /**
79
     * List all Products.
80
     * @link   https://stripe.com/docs/api/php#list_products
81
     *
82
     * @param  array|null         $params
83
     * @param  array|string|null  $options
84
     *
85
     * @return \Arcanedev\Stripe\Collection|array
86
     */
87
    public static function all($params = null, $options = null)
88
    {
89
        return self::scopedAll($params, $options);
90
    }
91
92
    /**
93
     * Delete a Product.
94
     * @link   https://stripe.com/docs/api/php#delete_product
95
     *
96
     * @param  array|null         $params
97
     * @param  array|string|null  $options
98
     *
99
     * @return self
100
     */
101 5
    public function delete($params = null, $options = null)
102
    {
103 5
        return $this->scopedDelete($params, $options);
104
    }
105
}
106