Bookings::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Resova\Endpoints\Baskets;
4
5
use Resova\Client;
6
use Resova\Models\BookingRequest;
7
8
class Bookings extends Client
9
{
10
    /**
11
     * Create a basket
12
     * Creates a new basket object.
13
     *
14
     * @param BookingRequest $booking
15
     *
16
     * @return $this
17
     */
18
    public function create(BookingRequest $booking): self
19
    {
20
        $booking->setRequired([
21
            'instance_id',
22
            'quantities'
23
        ]);
24
25
        // Set HTTP params
26
        $this->type     = 'post';
27
        $this->endpoint = '/baskets/' . $this->basket_id . '/bookings';
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

27
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/bookings';
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Bookings. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
        $this->params   = $booking;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Retrieve a basket booking
35
     * Retrieves the details of a basket booking. Provide the unique id for the basket booking.
36
     *
37
     * @param int $booking_id The basket booking id
38
     *
39
     * @return $this
40
     */
41
    public function __invoke(int $booking_id): self
42
    {
43
        $this->booking_id = $booking_id;
0 ignored issues
show
Bug Best Practice introduced by
The property booking_id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
45
        // Set HTTP params
46
        $this->type     = 'get';
47
        $this->endpoint = '/baskets/' . $this->basket_id . '/bookings/' . $booking_id;
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

47
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/bookings/' . $booking_id;
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Bookings. Since you implemented __get, consider adding a @property annotation.
Loading history...
48
49
        return $this;
50
    }
51
52
    /**
53
     * Delete a basket booking
54
     * Permanently deletes a basket booking. It cannot be undone.
55
     *
56
     * @return $this
57
     */
58
    public function delete(): self
59
    {
60
        // Set HTTP params
61
        $this->type     = 'delete';
62
        $this->endpoint = '/baskets/' . $this->basket_id . '/bookings/' . $this->booking_id;
0 ignored issues
show
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Bookings. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

62
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/bookings/' . $this->booking_id;
Loading history...
63
64
        return $this;
65
    }
66
67
    /**
68
     * Update a basket booking
69
     * Updates the specified basket booking by setting the values of the parameters passed.
70
     * Any parameters not provided will be left unchanged.
71
     * This request accepts mostly the same arguments as the basket booking creation call.
72
     *
73
     * @param null|BookingRequest $booking
74
     *
75
     * @return $this
76
     */
77
    public function update(BookingRequest $booking = null): self
78
    {
79
        // Set HTTP params
80
        $this->type     = 'put';
81
        $this->endpoint = '/baskets/' . $this->basket_id . '/bookings';
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

81
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/bookings';
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Bookings. Since you implemented __get, consider adding a @property annotation.
Loading history...
82
        $this->params   = $booking;
83
84
        return $this;
85
    }
86
87
    /**
88
     * List basket bookings
89
     * Returns a list of your basket bookings.
90
     * The basket bookings are returned sorted by creation date, with the most recent basket booking appearing first.
91
     *
92
     * @return $this
93
     */
94
    public function all(): self
95
    {
96
        // Set HTTP params
97
        $this->type     = 'get';
98
        $this->endpoint = '/baskets/' . $this->basket_id . '/bookings';
0 ignored issues
show
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Bookings. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

98
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/bookings';
Loading history...
99
100
        return $this;
101
    }
102
}
103