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

Instances   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
c 1
b 0
f 1
dl 0
loc 43
ccs 14
cts 14
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
A pricing() 0 13 1
1
<?php
2
3
namespace Resova\Endpoints\Availability;
4
5
use Resova\Endpoints\Availability;
6
use Resova\Models\Instance;
7
use Resova\Models\InstancePricing;
8
use Resova\Models\Pricing;
9
10
class Instances extends Availability
11
{
12
    /**
13
     * Retrieve an instance
14
     * Retrieve the details of a specific instance.
15
     *
16
     * @param string $instance_id The Instance Id
17
     *
18
     * @return $this
19
     */
20 3
    public function __invoke(string $instance_id): self
21
    {
22 3
        $this->instance_id = $instance_id;
0 ignored issues
show
Bug Best Practice introduced by
The property instance_id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
24
        // Set HTTP params
25 3
        $this->type     = 'get';
26 3
        $this->endpoint = '/availability/instance/' . $instance_id;
27 3
        $this->response = Instance::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...
28
29 3
        return $this;
30
    }
31
32
    /**
33
     * Retrieve instance pricing
34
     * Retrieve the pricing for an instance for the quantities passed.
35
     *
36
     * @param null|Pricing $pricing
37
     *
38
     * @return $this
39
     */
40 1
    public function pricing(Pricing $pricing): self
41
    {
42 1
        $pricing->setRequired([
43 1
            'quantities'
44
        ]);
45
46
        // Set HTTP params
47 1
        $this->type     = 'post';
48 1
        $this->endpoint = '/availability/instance/' . $this->instance_id . '/pricing';
49 1
        $this->params   = $pricing;
50 1
        $this->response = InstancePricing::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...
51
52 1
        return $this;
53
    }
54
55
}
56