Passed
Push — master ( a56982...6b40da )
by Raza
01:26
created

ProductsFamilies::product_family_products()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Srmklive\Chargify\Traits\ChargifyAPI;
4
5
trait ProductsFamilies
6
{
7
    /**
8
     * Create a product family.
9
     *
10
     * @param array $data
11
     *
12
     * @return array
13
     */
14
    public function product_family_create(array $data): array
15
    {
16
        $this->apiEndPoint = '/product_families.json';
17
18
        $this->verb = 'post';
19
20
        $this->options['json'] = [
0 ignored issues
show
Bug Best Practice introduced by
The property options does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
            'product_family' => $data,
22
        ];
23
24
        return $this->doChargifyRequest();
0 ignored issues
show
Bug introduced by
It seems like doChargifyRequest() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ doChargifyRequest();
Loading history...
25
    }
26
27
    /**
28
     * Get details for a product family.
29
     *
30
     * @param int $family_id
31
     *
32
     * @return array
33
     */
34
    public function product_family_details(int $family_id): array
35
    {
36
        $this->apiEndPoint = "/product_families/{$family_id}.json";
37
38
        $this->verb = 'get';
39
40
        return $this->doChargifyRequest();
41
    }
42
43
    /**
44
     * Create a product family.
45
     *
46
     * @return array
47
     */
48
    public function product_families_list(): array
49
    {
50
        $this->apiEndPoint = '/product_families.json';
51
52
        $this->verb = 'get';
53
54
        return $this->doChargifyRequest();
55
    }
56
57
    /**
58
     * Get products list for a product family.
59
     *
60
     * @param int $family_id
61
     *
62
     * @return array
63
     */
64
    public function product_family_products(int $family_id): array
65
    {
66
        $this->apiEndPoint = "/product_families/{$family_id}/products.json";
67
68
        $this->verb = 'get';
69
70
        return $this->doChargifyRequest();
71
    }
72
}
73