Completed
Push — master ( 9cfcfd...a0da2a )
by Mr
01:55
created

Availability   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 111
Duplicated Lines 14.41 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 16
loc 111
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A update() 0 8 1
A delete() 0 8 1
A search() 0 8 1
A createBatch() 0 8 1
A updateStartingAt() 0 8 1
A deleteStartingAt() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Rezdy\Endpoints;
4
5
use Rezdy\Client;
6
use Rezdy\Interfaces\AvailabilityInterface;
7
use Rezdy\Interfaces\QueryInterface;
8
9
class Availability extends Client implements AvailabilityInterface
10
{
11
    /**
12
     * Create availability
13
     *
14
     * @return \Rezdy\Interfaces\QueryInterface
15
     */
16
    public function create(): QueryInterface
17
    {
18
        // Set HTTP params
19
        $this->type     = 'post';
20
        $this->endpoint = '/availability';
21
22
        return $this;
23
    }
24
25
    /**
26
     * Update availability
27
     *
28
     * @param string $sessionId
29
     *
30
     * @return \Rezdy\Interfaces\QueryInterface
31
     */
32
    public function update(string $sessionId): QueryInterface
33
    {
34
        // Set HTTP params
35
        $this->type     = 'put';
36
        $this->endpoint = '/availability/' . $sessionId;
37
38
        return $this;
39
    }
40
41
    /**
42
     * Delete availability
43
     *
44
     * @param string $sessionId
45
     *
46
     * @return \Rezdy\Interfaces\QueryInterface
47
     */
48
    public function delete(string $sessionId): QueryInterface
49
    {
50
        // Set HTTP params
51
        $this->type     = 'delete';
52
        $this->endpoint = '/availability/' . $sessionId;
53
54
        return $this;
55
    }
56
57
    /**
58
     * Search availability
59
     *
60
     * @return \Rezdy\Interfaces\QueryInterface
61
     */
62
    public function search(): QueryInterface
63
    {
64
        // Set HTTP params
65
        $this->type     = 'get';
66
        $this->endpoint = '/availability';
67
68
        return $this;
69
    }
70
71
    /**
72
     * Create availability batch
73
     *
74
     * @return \Rezdy\Interfaces\QueryInterface
75
     */
76
    public function createBatch(): QueryInterface
77
    {
78
        // Set HTTP params
79
        $this->type     = 'post';
80
        $this->endpoint = '/availability/batch';
81
82
        return $this;
83
    }
84
85
    /**
86
     * Update availability starting at
87
     *
88
     * @param string $productCode
89
     * @param string $startTimeLocal
90
     *
91
     * @return \Rezdy\Interfaces\QueryInterface
92
     */
93
    public function updateStartingAt(string $productCode, string $startTimeLocal): QueryInterface
94
    {
95
        // Set HTTP params
96
        $this->type     = 'put';
97
        $this->endpoint = '/availability/product/' . $productCode . '/startTimeLocal/' . $startTimeLocal;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Delete availability starting at
104
     *
105
     * @param string $productCode
106
     * @param string $startTimeLocal
107
     *
108
     * @return \Rezdy\Interfaces\QueryInterface
109
     */
110
    public function deleteStartingAt(string $productCode, string $startTimeLocal): QueryInterface
111
    {
112
        // Set HTTP params
113
        $this->type     = 'delete';
114
        $this->endpoint = '/availability/product/' . $productCode . '/startTimeLocal/' . $startTimeLocal;
115
116
        return $this;
117
    }
118
119
}
120