1
1
<?php namespace Tripleseat ;
2
2
3
- use Generator ;
4
3
use Psr \Http \Client \ClientInterface ;
5
4
use Tripleseat \Exceptions \InvalidArgumentException ;
6
5
use Tripleseat \Exceptions \InvalidAuthConfiguration ;
18
17
* @property Services\Location location
19
18
* @property Services\Site site
20
19
* @property Services\User user
21
- *
22
- * @method Generator allAccount(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
23
- * @method Generator searchAccount(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
24
- * @method getAccount(int $id)
25
- * @method createAccount(array $account)
26
- * @method updateAccount(int $id, array $account)
27
- * @method deleteAccount(int $id)
28
- *
29
- * @method Generator allBooking(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
30
- * @method Generator searchBooking(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
31
- * @method getBooking(int $id)
32
- * @method createBooking(array $booking)
33
- * @method updateBooking(int $id, array $booking)
34
- * @method deleteBooking(int $id)
35
- *
36
- * @method Generator allContact(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
37
- * @method Generator searchContact(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
38
- * @method getContact(int $id)
39
- * @method createContact(array $contact)
40
- * @method updateContact(int $id, array $contact)
41
- * @method deleteContact(int $id)
42
- *
43
- * @method Generator allEvent(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
44
- * @method Generator searchEvent(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
45
- * @method getEvent(int $id)
46
- * @method createEvent(array $event)
47
- * @method updateEvent(int $id, array $event)
48
- * @method deleteEvent(int $id)
49
- *
50
- * @method Generator allLead(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
51
- * @method Generator searchLead(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
52
- * @method getLead(int $id)
53
- * @method createLead(array $lead, array $additionalData = [])
54
- * @method Generator formsLead()
55
- *
56
- * @method Generator allLocation()
57
- *
58
- * @method Generator allSite()
59
- *
60
- * @method Generator allUser(int $fromPage = 1, int $untilPage = PHP_INT_MAX)
61
- * @method Generator searchUser(array $parameters, int $fromPage = 1, int $untilPage = PHP_INT_MAX)
62
- * @method getUser(int $id)
63
20
*/
64
21
class Tripleseat implements \ArrayAccess
65
22
{
@@ -141,48 +98,12 @@ public function __get(string $name)
141
98
}
142
99
143
100
/**
144
- * @param $name
145
- * @param $arguments
146
- * @return mixed
147
- * @throws InvalidService
148
- */
149
- public function __call ($ name , $ arguments )
150
- {
151
- if ([$ service , $ method ] = $ this ->extractServiceAndMethod ($ name )) {
152
- $ service = $ this ->__get ($ service );
153
-
154
- if (!empty ($ method )) {
155
- return call_user_func_array ([$ service , $ method ], $ arguments );
156
- }
157
- }
158
-
159
- throw new InvalidService ($ name );
160
- }
161
-
162
- /**
163
- * Parses a string to check if the last part matches any of the defined
164
- * services and returns an array with the service and the string in front
165
- * of the service as the method name.
166
- *
167
- * @param string $haystack
168
- * @return array|null
101
+ * @param int $offset
102
+ * @return bool
169
103
*/
170
- private function extractServiceAndMethod (string $ haystack )
171
- {
172
- $ haystack = strtolower ($ haystack );
173
- $ needles = array_keys ($ this ->availableServices );
174
-
175
- foreach ($ needles as $ needle ) {
176
- if ($ needle !== '' && substr_compare ($ haystack , (string )$ needle , -strlen ($ needle ), null , true ) === 0 ) {
177
- return [strtolower ($ needle ), strstr ($ haystack , (string )$ needle , true )];
178
- }
179
- }
180
-
181
- return null ;
182
- }
183
-
184
- private function sites ()
104
+ public function offsetExists ($ offset )
185
105
{
106
+ // Load and cache the sites
186
107
if (is_null ($ this ->sites )) {
187
108
$ this ->sites = [];
188
109
@@ -191,20 +112,11 @@ private function sites()
191
112
}
192
113
}
193
114
194
- return $ this ->sites ;
195
- }
196
-
197
- /**
198
- * @param mixed $offset
199
- * @return bool
200
- */
201
- public function offsetExists ($ offset )
202
- {
203
- return array_key_exists ($ offset , $ this ->sites ());
115
+ return array_key_exists ($ offset , $ this ->sites );
204
116
}
205
117
206
118
/**
207
- * @param mixed $offset
119
+ * @param int $offset
208
120
* @return Tripleseat
209
121
* @throws InvalidSite
210
122
*/
0 commit comments