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

Calendars   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
c 1
b 0
f 1
dl 0
loc 31
ccs 8
cts 9
cp 0.8889
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 2
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