Passed
Push — master ( fc2f89...038734 )
by compolom
02:33
created

Calendars::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.0054

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 9
c 1
b 0
f 1
nc 2
nop 3
dl 0
loc 19
ccs 8
cts 9
cp 0.8889
crap 2.0054
rs 9.9666
1
<?php
2
3
namespace Resova\Endpoints\Availability;
4
5
use Resova\Endpoints\Availability;
6
7
class Calendars extends Availability
8
{
9
    /**
10
     * Retrieve daily availability
11
     * Retrieve the instances for items across a date range.
12
     *
13
     * @param string $start_date The start date for the availability range
14
     * @param string $end_date   The end date for the availability range.
15
     * @param array  $item_ids   Limit the availability results by item ids
16
     *
17
     * @return $this
18
     */
19 1
    public function __invoke(string $start_date, string $end_date, array $item_ids = []): self
20
    {
21
        // Default parameters
22
        $params = [
23 1
            'start_date' => $start_date,
24 1
            'end_date'   => $end_date,
25
        ];
26
27
        // Optional: Limit the availability results by item ids
28 1
        if (!empty($item_ids)) {
29
            $params['item_ids'] = implode(',', $item_ids);
30
        }
31
32
        // Set HTTP params
33 1
        $this->type     = 'get';
34 1
        $this->endpoint = '/availability/calendar' . '?' . http_build_query($params);
35 1
        $this->response = \Resova\Models\Availability::class;
0 ignored issues
show
Bug Best Practice introduced by
The property response does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
37 1
        return $this;
38
    }
39
40
}
41