Code Duplication    Length = 85-85 lines in 2 locations

src/Models/Term.php 1 location

@@ 7-91 (lines=85) @@
4
5
use Codexshaper\WooCommerce\Facades\WooCommerce;
6
7
class Term extends BaseModel
8
{
9
    protected $endpoint;
10
11
    /**
12
     * Retrieve all Items.
13
     *
14
     * @param integer $attribute_id
15
     * @param array $options
16
     *
17
     * @return array
18
     */
19
    protected function all($attribute_id, $options = [])
20
    {
21
        return WooCommerce::all("products/attributes/{$attribute_id}/terms", $options);
22
    }
23
24
    /**
25
     * Retrieve single Item.
26
     *
27
     * @param int   $attribute_id
28
     * @param int   $id
29
     * @param array $options
30
     *
31
     * @return object
32
     */
33
    protected function find($attribute_id, $id, $options = [])
34
    {
35
        return collect(WooCommerce::find("products/attributes/{$attribute_id}/terms/{$id}", $options));
36
    }
37
38
    /**
39
     * Create new Item.
40
     *
41
     * @param int   $attribute_id
42
     * @param array $data
43
     *
44
     * @return object
45
     */
46
    protected function create($attribute_id, $data)
47
    {
48
        return WooCommerce::create("products/attributes/{$attribute_id}/terms", $data);
49
    }
50
51
    /**
52
     * Update Existing Item.
53
     *
54
     * @param int   $attribute_id
55
     * @param int   $id
56
     * @param array $data
57
     *
58
     * @return object
59
     */
60
    protected function update($attribute_id, $id, $data)
61
    {
62
        return WooCommerce::update("products/attributes/{$attribute_id}/terms/{$id}", $data);
63
    }
64
65
    /**
66
     * Destroy Item.
67
     *
68
     * @param int   $attribute_id
69
     * @param int   $id
70
     * @param array $options
71
     *
72
     * @return object
73
     */
74
    protected function delete($attribute_id, $id, $options = [])
75
    {
76
        return WooCommerce::delete("products/attributes/{$attribute_id}/terms/{$id}", $options);
77
    }
78
79
    /**
80
     * Batch Update.
81
     *
82
     * @param int   $attribute_id
83
     * @param array $data
84
     *
85
     * @return object
86
     */
87
    protected function batch($attribute_id, $data)
88
    {
89
        return WooCommerce::create("products/attributes/{$attribute_id}/terms/batch", $data);
90
    }
91
}
92

src/Models/Variation.php 1 location

@@ 7-91 (lines=85) @@
4
5
use Codexshaper\WooCommerce\Facades\WooCommerce;
6
7
class Variation extends BaseModel
8
{
9
    protected $endpoint;
10
11
    /**
12
     * Retrieve all Items.
13
     *
14
     * @param integer $product_id
15
     * @param array $options
16
     *
17
     * @return array
18
     */
19
    protected function all($product_id, $options = [])
20
    {
21
        return WooCommerce::all("products/{$product_id}/variations", $options);
22
    }
23
24
    /**
25
     * Retrieve single Item.
26
     *
27
     * @param int   $product_id
28
     * @param int   $id
29
     * @param array $options
30
     *
31
     * @return object
32
     */
33
    protected function find($product_id, $id, $options = [])
34
    {
35
        return collect(WooCommerce::find("products/{$product_id}/variations/{$id}", $options));
36
    }
37
38
    /**
39
     * Create new Item.
40
     *
41
     * @param int   $product_id
42
     * @param array $data
43
     *
44
     * @return object
45
     */
46
    protected function create($product_id, $data)
47
    {
48
        return WooCommerce::create("products/{$product_id}/variations", $data);
49
    }
50
51
    /**
52
     * Update Existing Item.
53
     *
54
     * @param int   $product_id
55
     * @param int   $id
56
     * @param array $data
57
     *
58
     * @return object
59
     */
60
    protected function update($product_id, $id, $data)
61
    {
62
        return WooCommerce::update("products/{$product_id}/variations/{$id}", $data);
63
    }
64
65
    /**
66
     * Destroy Item.
67
     *
68
     * @param int   $product_id
69
     * @param int   $id
70
     * @param array $options
71
     *
72
     * @return object
73
     */
74
    protected function delete($product_id, $id, $options = [])
75
    {
76
        return WooCommerce::delete("products/{$product_id}/variations/{$id}", $options);
77
    }
78
79
    /**
80
     * Batch Update.
81
     *
82
     * @param int   $product_id
83
     * @param array $data
84
     *
85
     * @return object
86
     */
87
    protected function batch($product_id, $data)
88
    {
89
        return WooCommerce::create("products/{$product_id}/variations/batch", $data);
90
    }
91
}
92