1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Gueststream\PMS\IQWare\API; |
4
|
|
|
|
5
|
|
View Code Duplication |
class ArrayOfB2BAnywhere implements \ArrayAccess, \Iterator, \Countable |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @var B2BAnywhere[] $B2BAnywhere |
10
|
|
|
*/ |
11
|
|
|
protected $B2BAnywhere = null; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @return B2BAnywhere[] |
21
|
|
|
*/ |
22
|
|
|
public function getB2BAnywhere() |
23
|
|
|
{ |
24
|
|
|
return $this->B2BAnywhere; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param B2BAnywhere[] $B2BAnywhere |
29
|
|
|
* @return \Gueststream\PMS\IQWare\API\ArrayOfB2BAnywhere |
30
|
|
|
*/ |
31
|
|
|
public function setB2BAnywhere(array $B2BAnywhere = null) |
32
|
|
|
{ |
33
|
|
|
$this->B2BAnywhere = $B2BAnywhere; |
|
|
|
|
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* ArrayAccess implementation |
39
|
|
|
* |
40
|
|
|
* @param mixed $offset An offset to check for |
41
|
|
|
* @return boolean true on success or false on failure |
42
|
|
|
*/ |
43
|
|
|
public function offsetExists($offset) |
44
|
|
|
{ |
45
|
|
|
return isset($this->B2BAnywhere[$offset]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* ArrayAccess implementation |
50
|
|
|
* |
51
|
|
|
* @param mixed $offset The offset to retrieve |
52
|
|
|
* @return B2BAnywhere |
53
|
|
|
*/ |
54
|
|
|
public function offsetGet($offset) |
55
|
|
|
{ |
56
|
|
|
return $this->B2BAnywhere[$offset]; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* ArrayAccess implementation |
61
|
|
|
* |
62
|
|
|
* @param mixed $offset The offset to assign the value to |
63
|
|
|
* @param B2BAnywhere $value The value to set |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function offsetSet($offset, $value) |
67
|
|
|
{ |
68
|
|
|
$this->B2BAnywhere[$offset] = $value; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* ArrayAccess implementation |
73
|
|
|
* |
74
|
|
|
* @param mixed $offset The offset to unset |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public function offsetUnset($offset) |
78
|
|
|
{ |
79
|
|
|
unset($this->B2BAnywhere[$offset]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Iterator implementation |
84
|
|
|
* |
85
|
|
|
* @return B2BAnywhere Return the current element |
86
|
|
|
*/ |
87
|
|
|
public function current() |
88
|
|
|
{ |
89
|
|
|
return current($this->B2BAnywhere); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Iterator implementation |
94
|
|
|
* Move forward to next element |
95
|
|
|
* |
96
|
|
|
* @return void |
97
|
|
|
*/ |
98
|
|
|
public function next() |
99
|
|
|
{ |
100
|
|
|
next($this->B2BAnywhere); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Iterator implementation |
105
|
|
|
* |
106
|
|
|
* @return string|null Return the key of the current element or null |
107
|
|
|
*/ |
108
|
|
|
public function key() |
109
|
|
|
{ |
110
|
|
|
return key($this->B2BAnywhere); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Iterator implementation |
115
|
|
|
* |
116
|
|
|
* @return boolean Return the validity of the current position |
117
|
|
|
*/ |
118
|
|
|
public function valid() |
119
|
|
|
{ |
120
|
|
|
return $this->key() !== null; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Iterator implementation |
125
|
|
|
* Rewind the Iterator to the first element |
126
|
|
|
* |
127
|
|
|
* @return void |
128
|
|
|
*/ |
129
|
|
|
public function rewind() |
130
|
|
|
{ |
131
|
|
|
reset($this->B2BAnywhere); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Countable implementation |
136
|
|
|
* |
137
|
|
|
* @return B2BAnywhere Return count of elements |
138
|
|
|
*/ |
139
|
|
|
public function count() |
140
|
|
|
{ |
141
|
|
|
return count($this->B2BAnywhere); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.