SubscriptionController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
dl 0
loc 67
c 1
b 0
f 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 9 1
A __construct() 0 3 1
A create() 0 9 1
A index() 0 8 1
A read() 0 8 1
1
<?php
2
3
namespace ItsMeLePassos\CafeApi;
4
5
use ItsMeLePassos\CafeApi\API\CafeApiController;
6
7
class SubscriptionController extends CafeApiController
8
{
9
    /**
10
     * SubscriptionController constructor.
11
     * @param string $apiUrl
12
     * @param string $email
13
     * @param string $password
14
     */
15
    public function __construct(string $apiUrl, string $email, string $password)
16
    {
17
        parent::__construct($apiUrl, $email, $password);
18
    }
19
20
    /**
21
     * @return SubscriptionController
22
     */
23
    public function index(): SubscriptionController
24
    {
25
        $this->request(
26
            "GET",
27
            "/subscription"
28
        );
29
30
        return $this;
31
    }
32
33
    /**
34
     * @param array $fields
35
     * @return SubscriptionController
36
     */
37
    public function create(array $fields): SubscriptionController
38
    {
39
        $this->request(
40
            "POST",
41
            "/subscription",
42
            $fields
43
        );
44
45
        return $this;
46
    }
47
48
    /**
49
     * @return SubscriptionController
50
     */
51
    public function read(): SubscriptionController
52
    {
53
        $this->request(
54
            "GET",
55
            "/subscription/plans"
56
        );
57
58
        return $this;
59
    }
60
61
    /**
62
     * @param array $fields
63
     * @return SubscriptionController
64
     */
65
    public function update(array $fields): SubscriptionController
66
    {
67
        $this->request(
68
            "PUT",
69
            "/subscription",
70
            $fields
71
        );
72
73
        return $this;
74
    }
75
}
76