Attribute::getTerm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Codexshaper\WooCommerce\PHP\Models;
4
5
use Codexshaper\WooCommerce\PHP\Traits\QueryBuilderTrait;
6
7
class Attribute extends BaseModel
8
{
9
    use QueryBuilderTrait;
10
11
    protected $endpoint = 'products/attributes';
12
13
    /**
14
     * Retrieve all Items.
15
     *
16
     * @param int   $attribute_id
17
     * @param array $options
18
     *
19
     * @return array
20
     */
21
    protected function getTerms($attribute_id, $options = [])
22
    {
23
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
24
25
        return self::all($options);
26
    }
27
28
    /**
29
     * Retrieve single Item.
30
     *
31
     * @param int   $attribute_id
32
     * @param int   $term_id
33
     * @param array $options
34
     *
35
     * @return object
36
     */
37
    protected function getTerm($attribute_id, $term_id, $options = [])
38
    {
39
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
40
41
        return self::find($term_id, $options);
42
    }
43
44
    /**
45
     * Create new Item.
46
     *
47
     * @param int   $attribute_id
48
     * @param array $data
49
     *
50
     * @return object
51
     */
52
    protected function addTerm($attribute_id, $data)
53
    {
54
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
55
56
        return self::create($data);
57
    }
58
59
    /**
60
     * Update Existing Item.
61
     *
62
     * @param int   $attribute_id
63
     * @param int   $term_id
64
     * @param array $data
65
     *
66
     * @return object
67
     */
68
    protected function updateTerm($attribute_id, $term_id, $data)
69
    {
70
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
71
72
        return self::update($term_id, $data);
73
    }
74
75
    /**
76
     * Destroy Item.
77
     *
78
     * @param int   $attribute_id
79
     * @param int   $term_id
80
     * @param array $options
81
     *
82
     * @return object
83
     */
84
    protected function deleteTerm($attribute_id, $term_id, $options = [])
85
    {
86
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
87
88
        return self::delete($term_id, $options);
89
    }
90
91
    /**
92
     * Batch Update.
93
     *
94
     * @param int   $attribute_id
95
     * @param array $data
96
     *
97
     * @return object
98
     */
99
    protected function batchTerm($attribute_id, $data)
100
    {
101
        $this->endpoint = "products/attributes/{$attribute_id}/terms";
102
103
        return self::batch($data);
104
    }
105
}
106