GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( e5b8eb...47d764 )
by Igor
01:54 queued 12s
created
src/Route4Me/V5/AddressBook/ResponseAddress.php 2 patches
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -15,279 +15,279 @@
 block discarded – undo
15 15
  */
16 16
 class ResponseAddress extends Common
17 17
 {
18
-    /**
19
-     * Time when the contact was created.
20
-     * @example 1627120286
21
-     */
22
-    public ?int $created_timestamp = null;
23
-
24
-    /**
25
-     * Unique ID of the address.
26
-     * @example 1
27
-     */
28
-    public ?int $address_id = null;
29
-
30
-    /**
31
-     * A group the contact belongs.
32
-     */
33
-    public ?string $address_group = null;
34
-
35
-    /**
36
-     * Address group.
37
-     * @example 'Jenkins Ways'
38
-     */
39
-    public ?string $address_alias = null;
40
-
41
-    /**
42
-     * The route Address Line 1.
43
-     * @example '999 Aurelio Summit, Jamirtown, CO 52979-8465'
44
-     */
45
-    public ?string $address_1 = null;
46
-
47
-    /**
48
-     * The route Address Line 2 which is not used for geocoding.
49
-     */
50
-    public ?string $address_2 = null;
51
-
52
-    /**
53
-     * A member the address assigned to.
54
-     * @example 1
55
-     */
56
-    public ?int $member_id = null;
57
-
58
-    /**
59
-     * The first name of the receiving address.
60
-     * @example 'Keyon'
61
-     */
62
-    public ?string $first_name = null;
63
-
64
-    /**
65
-     * The last name of the receiving party.
66
-     * @example 'Will'
67
-     */
68
-    public ?string $last_name = null;
69
-
70
-    /**
71
-     * The contact's email.
72
-     */
73
-    public ?string $address_email = null;
74
-
75
-    /**
76
-     * The contact's phone number.
77
-     */
78
-    public ?string $address_phone_number = null;
79
-
80
-    /**
81
-     * The city the address is located in.
82
-     */
83
-    public ?string $address_city = null;
84
-
85
-    /**
86
-     * The state the address is located in.
87
-     * @example '10'
88
-     */
89
-    public ?string $address_state_id = null;
90
-
91
-    /**
92
-     * The country the address is located in.
93
-     * @example '223'
94
-     */
95
-    public ?string $address_country_id = null;
96
-
97
-    /**
98
-     * The zip code the address is located in.
99
-     */
100
-    public ?string $address_zip = null;
101
-
102
-    /**
103
-     * A latitude of the contact's cached position.
104
-     * @example -79.102999
105
-     */
106
-    public ?float $cached_lat = null;
107
-
108
-    /**
109
-     * A longitude of the contact's cached position.
110
-     * @example -162.156663
111
-     */
112
-    public ?float $cached_lng = null;
113
-
114
-    /**
115
-     * A latitude of the contact's curbside.
116
-     * @example -79.102999
117
-     */
118
-    public ?float $curbside_lat = null;
119
-
120
-    /**
121
-     * A longitude of the contact's curbside.
122
-     * @example -162.156663
123
-     */
124
-    public ?float $curbside_lng = null;
125
-
126
-    /**
127
-     * An array of the contact's custom field-value pairs.
128
-     * @example ['custom_data_key' => 'custom_data_value']
129
-     */
130
-    public ?array $address_custom_data = null;
131
-
132
-    /**
133
-     * Array of the trip schedules to a location.
134
-     * @var Schedule[]
135
-     */
136
-    public ?array $schedule = null;
137
-
138
-    /**
139
-     * Array of the dates, which should be excluded from a trip schedule to a location.
140
-     * Also can be a date string with the 'YYYY-MM-DD' format.
141
-     * @var string|string[]
142
-     * @example ['2019-12-12']
143
-     */
144
-    public $schedule_blacklist = null;
145
-
146
-    /**
147
-     * Number of the routes containing the contact.
148
-     */
149
-    public ?int $in_route_count = null;
150
-
151
-    /**
152
-     * How many times visited the contact.
153
-     */
154
-    public ?int $visited_count = null;
155
-
156
-    /**
157
-     * When the contact was last visited.
158
-     */
159
-    public ?int $last_visited_timestamp = null;
160
-
161
-    /**
162
-     * When the contact was last routed.
163
-     */
164
-    public ?int $last_routed_timestamp = null;
165
-
166
-    /**
167
-     * Start of the contact's local time window.
168
-     */
169
-    public ?int $local_time_window_start = null;
170
-
171
-    /**
172
-     * End of the contact's local time window.
173
-     */
174
-    public ?int $local_time_window_end = null;
175
-
176
-    /**
177
-     * Start of the contact's second local time window.
178
-     */
179
-    public ?int $local_time_window_start_2 = null;
180
-
181
-    /**
182
-     * End of the contact's second local time window.
183
-     */
184
-    public ?int $local_time_window_end_2 = null;
185
-
186
-    /**
187
-     * The service time at the contact's address.
188
-     */
189
-    public ?int $service_time = null;
190
-
191
-    /**
192
-     * The contact's local timezone.
193
-     */
194
-    public ?string $local_timezone_string = null;
195
-
196
-    /**
197
-     * The contact's color on the map.
198
-     * @example '000000'
199
-     */
200
-    public ?string $color = null;
201
-
202
-    /**
203
-     * The contact's icon on the map.
204
-     */
205
-    public ?string $address_icon = null;
206
-
207
-    /**
208
-     * The contact's stop type.
209
-     * String array, available types: 'DELIVERY', 'PICKUP',
210
-     *   'BREAK', 'MEETUP', 'SERVICE', 'VISIT', 'DRIVEBY'
211
-     */
212
-    public ?string $address_stop_type = null;
213
-
214
-    /**
215
-     * The cubic volume of the cargo being delivered or picked up at the address.
216
-     */
217
-    public ?float $address_cube = null;
218
-
219
-    /**
220
-     * The item quantity of the cargo being delivered or picked up at the address.
221
-     */
222
-    public ?float $address_pieces = null;
223
-
224
-    /**
225
-     * The reference number of the address.
226
-     */
227
-    public ?string $address_reference_no = null;
228
-
229
-    /**
230
-     * The total revenue for the address.
231
-     */
232
-    public ?float $address_revenue = null;
233
-
234
-    /**
235
-     * Weight of the cargo being delivered or picked up at the address.
236
-     */
237
-    public ?float $address_weight = null;
238
-
239
-    /**
240
-     * If present, the priority will sequence addresses in all the optimal routes so that
241
-     * higher priority addresses are general at the beginning of the route sequence.
242
-     * 0 is the highest priority, n has higher priority than n + 1
243
-     */
244
-    public ?int $address_priority = null;
245
-
246
-    /**
247
-     * The customer purchase order for the address.
248
-     */
249
-    public ?string $address_customer_po = null;
250
-
251
-    /**
252
-     * If true, the address is eligible to pickup.
253
-     */
254
-    public ?bool $eligible_pickup = null;
255
-
256
-    /**
257
-     * If true, the addrss is eligible to depot.
258
-     */
259
-    public ?bool $eligible_depot = null;
260
-
261
-    /**
262
-     * If true, the addrss is eligible to depot.
263
-     */
264
-    public ?AssignedTo $assigned_to = null;
265
-
266
-    public function __construct(?array $params = null)
267
-    {
268
-        if ($params !== null) {
269
-            foreach ($this as $key => $value) {
270
-                if (isset($params[$key])) {
271
-                    if ($key === 'schedule') {
272
-                        $this->{$key} = array();
273
-                        foreach ($params[$key] as $si_key => $si_value) {
274
-                            if (is_array($si_value)) {
275
-                                array_push($this->{$key}, new ScheduleItem($si_value));
276
-                            } elseif (is_object($si_value) && $si_value instanceof ScheduleItem) {
277
-                                array_push($this->{$key}, $si_value);
278
-                            }
279
-                        }
280
-                    } elseif ($key === 'assigned_to') {
281
-                        if (is_array($params[$key])) {
282
-                            $this->{$key} = new AssignedTo($params[$key]);
283
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof AssignedTo) {
284
-                            $this->{$key} = $params[$key];
285
-                        }
286
-                    } else {
287
-                        $this->{$key} = $params[$key];
288
-                    }
289
-                }
290
-            }
291
-        }
292
-    }
18
+	/**
19
+	 * Time when the contact was created.
20
+	 * @example 1627120286
21
+	 */
22
+	public ?int $created_timestamp = null;
23
+
24
+	/**
25
+	 * Unique ID of the address.
26
+	 * @example 1
27
+	 */
28
+	public ?int $address_id = null;
29
+
30
+	/**
31
+	 * A group the contact belongs.
32
+	 */
33
+	public ?string $address_group = null;
34
+
35
+	/**
36
+	 * Address group.
37
+	 * @example 'Jenkins Ways'
38
+	 */
39
+	public ?string $address_alias = null;
40
+
41
+	/**
42
+	 * The route Address Line 1.
43
+	 * @example '999 Aurelio Summit, Jamirtown, CO 52979-8465'
44
+	 */
45
+	public ?string $address_1 = null;
46
+
47
+	/**
48
+	 * The route Address Line 2 which is not used for geocoding.
49
+	 */
50
+	public ?string $address_2 = null;
51
+
52
+	/**
53
+	 * A member the address assigned to.
54
+	 * @example 1
55
+	 */
56
+	public ?int $member_id = null;
57
+
58
+	/**
59
+	 * The first name of the receiving address.
60
+	 * @example 'Keyon'
61
+	 */
62
+	public ?string $first_name = null;
63
+
64
+	/**
65
+	 * The last name of the receiving party.
66
+	 * @example 'Will'
67
+	 */
68
+	public ?string $last_name = null;
69
+
70
+	/**
71
+	 * The contact's email.
72
+	 */
73
+	public ?string $address_email = null;
74
+
75
+	/**
76
+	 * The contact's phone number.
77
+	 */
78
+	public ?string $address_phone_number = null;
79
+
80
+	/**
81
+	 * The city the address is located in.
82
+	 */
83
+	public ?string $address_city = null;
84
+
85
+	/**
86
+	 * The state the address is located in.
87
+	 * @example '10'
88
+	 */
89
+	public ?string $address_state_id = null;
90
+
91
+	/**
92
+	 * The country the address is located in.
93
+	 * @example '223'
94
+	 */
95
+	public ?string $address_country_id = null;
96
+
97
+	/**
98
+	 * The zip code the address is located in.
99
+	 */
100
+	public ?string $address_zip = null;
101
+
102
+	/**
103
+	 * A latitude of the contact's cached position.
104
+	 * @example -79.102999
105
+	 */
106
+	public ?float $cached_lat = null;
107
+
108
+	/**
109
+	 * A longitude of the contact's cached position.
110
+	 * @example -162.156663
111
+	 */
112
+	public ?float $cached_lng = null;
113
+
114
+	/**
115
+	 * A latitude of the contact's curbside.
116
+	 * @example -79.102999
117
+	 */
118
+	public ?float $curbside_lat = null;
119
+
120
+	/**
121
+	 * A longitude of the contact's curbside.
122
+	 * @example -162.156663
123
+	 */
124
+	public ?float $curbside_lng = null;
125
+
126
+	/**
127
+	 * An array of the contact's custom field-value pairs.
128
+	 * @example ['custom_data_key' => 'custom_data_value']
129
+	 */
130
+	public ?array $address_custom_data = null;
131
+
132
+	/**
133
+	 * Array of the trip schedules to a location.
134
+	 * @var Schedule[]
135
+	 */
136
+	public ?array $schedule = null;
137
+
138
+	/**
139
+	 * Array of the dates, which should be excluded from a trip schedule to a location.
140
+	 * Also can be a date string with the 'YYYY-MM-DD' format.
141
+	 * @var string|string[]
142
+	 * @example ['2019-12-12']
143
+	 */
144
+	public $schedule_blacklist = null;
145
+
146
+	/**
147
+	 * Number of the routes containing the contact.
148
+	 */
149
+	public ?int $in_route_count = null;
150
+
151
+	/**
152
+	 * How many times visited the contact.
153
+	 */
154
+	public ?int $visited_count = null;
155
+
156
+	/**
157
+	 * When the contact was last visited.
158
+	 */
159
+	public ?int $last_visited_timestamp = null;
160
+
161
+	/**
162
+	 * When the contact was last routed.
163
+	 */
164
+	public ?int $last_routed_timestamp = null;
165
+
166
+	/**
167
+	 * Start of the contact's local time window.
168
+	 */
169
+	public ?int $local_time_window_start = null;
170
+
171
+	/**
172
+	 * End of the contact's local time window.
173
+	 */
174
+	public ?int $local_time_window_end = null;
175
+
176
+	/**
177
+	 * Start of the contact's second local time window.
178
+	 */
179
+	public ?int $local_time_window_start_2 = null;
180
+
181
+	/**
182
+	 * End of the contact's second local time window.
183
+	 */
184
+	public ?int $local_time_window_end_2 = null;
185
+
186
+	/**
187
+	 * The service time at the contact's address.
188
+	 */
189
+	public ?int $service_time = null;
190
+
191
+	/**
192
+	 * The contact's local timezone.
193
+	 */
194
+	public ?string $local_timezone_string = null;
195
+
196
+	/**
197
+	 * The contact's color on the map.
198
+	 * @example '000000'
199
+	 */
200
+	public ?string $color = null;
201
+
202
+	/**
203
+	 * The contact's icon on the map.
204
+	 */
205
+	public ?string $address_icon = null;
206
+
207
+	/**
208
+	 * The contact's stop type.
209
+	 * String array, available types: 'DELIVERY', 'PICKUP',
210
+	 *   'BREAK', 'MEETUP', 'SERVICE', 'VISIT', 'DRIVEBY'
211
+	 */
212
+	public ?string $address_stop_type = null;
213
+
214
+	/**
215
+	 * The cubic volume of the cargo being delivered or picked up at the address.
216
+	 */
217
+	public ?float $address_cube = null;
218
+
219
+	/**
220
+	 * The item quantity of the cargo being delivered or picked up at the address.
221
+	 */
222
+	public ?float $address_pieces = null;
223
+
224
+	/**
225
+	 * The reference number of the address.
226
+	 */
227
+	public ?string $address_reference_no = null;
228
+
229
+	/**
230
+	 * The total revenue for the address.
231
+	 */
232
+	public ?float $address_revenue = null;
233
+
234
+	/**
235
+	 * Weight of the cargo being delivered or picked up at the address.
236
+	 */
237
+	public ?float $address_weight = null;
238
+
239
+	/**
240
+	 * If present, the priority will sequence addresses in all the optimal routes so that
241
+	 * higher priority addresses are general at the beginning of the route sequence.
242
+	 * 0 is the highest priority, n has higher priority than n + 1
243
+	 */
244
+	public ?int $address_priority = null;
245
+
246
+	/**
247
+	 * The customer purchase order for the address.
248
+	 */
249
+	public ?string $address_customer_po = null;
250
+
251
+	/**
252
+	 * If true, the address is eligible to pickup.
253
+	 */
254
+	public ?bool $eligible_pickup = null;
255
+
256
+	/**
257
+	 * If true, the addrss is eligible to depot.
258
+	 */
259
+	public ?bool $eligible_depot = null;
260
+
261
+	/**
262
+	 * If true, the addrss is eligible to depot.
263
+	 */
264
+	public ?AssignedTo $assigned_to = null;
265
+
266
+	public function __construct(?array $params = null)
267
+	{
268
+		if ($params !== null) {
269
+			foreach ($this as $key => $value) {
270
+				if (isset($params[$key])) {
271
+					if ($key === 'schedule') {
272
+						$this->{$key} = array();
273
+						foreach ($params[$key] as $si_key => $si_value) {
274
+							if (is_array($si_value)) {
275
+								array_push($this->{$key}, new ScheduleItem($si_value));
276
+							} elseif (is_object($si_value) && $si_value instanceof ScheduleItem) {
277
+								array_push($this->{$key}, $si_value);
278
+							}
279
+						}
280
+					} elseif ($key === 'assigned_to') {
281
+						if (is_array($params[$key])) {
282
+							$this->{$key} = new AssignedTo($params[$key]);
283
+						} elseif (is_object($params[$key]) && $params[$key] instanceof AssignedTo) {
284
+							$this->{$key} = $params[$key];
285
+						}
286
+					} else {
287
+						$this->{$key} = $params[$key];
288
+					}
289
+				}
290
+			}
291
+		}
292
+	}
293 293
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 
266 266
     public function __construct(?array $params = null)
267 267
     {
268
-        if ($params !== null) {
268
+        if ($params!==null) {
269 269
             foreach ($this as $key => $value) {
270 270
                 if (isset($params[$key])) {
271
-                    if ($key === 'schedule') {
271
+                    if ($key==='schedule') {
272 272
                         $this->{$key} = array();
273 273
                         foreach ($params[$key] as $si_key => $si_value) {
274 274
                             if (is_array($si_value)) {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                                 array_push($this->{$key}, $si_value);
278 278
                             }
279 279
                         }
280
-                    } elseif ($key === 'assigned_to') {
280
+                    } elseif ($key==='assigned_to') {
281 281
                         if (is_array($params[$key])) {
282 282
                             $this->{$key} = new AssignedTo($params[$key]);
283 283
                         } elseif (is_object($params[$key]) && $params[$key] instanceof AssignedTo) {
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/ResponsePagination.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,26 +13,26 @@
 block discarded – undo
13 13
  */
14 14
 class ResponsePagination extends ResponseAll
15 15
 {
16
-    /**
17
-     * Current page in the adddress book collection.
18
-     * @example 1
19
-     */
20
-    public ?int $current_page = null;
16
+	/**
17
+	 * Current page in the adddress book collection.
18
+	 * @example 1
19
+	 */
20
+	public ?int $current_page = null;
21 21
 
22
-    /**
23
-     * Last page in the adddress book collection.
24
-     * @example 3
25
-     */
26
-    public ?int $last_page = null;
22
+	/**
23
+	 * Last page in the adddress book collection.
24
+	 * @example 3
25
+	 */
26
+	public ?int $last_page = null;
27 27
 
28
-    /**
29
-     * Adddress book number per page.
30
-     * @example 30
31
-     */
32
-    public ?int $per_page = null;
28
+	/**
29
+	 * Adddress book number per page.
30
+	 * @example 30
31
+	 */
32
+	public ?int $per_page = null;
33 33
 
34
-    public function __construct(?array $params = null)
35
-    {
36
-        parent::__construct($params);
37
-    }
34
+	public function __construct(?array $params = null)
35
+	{
36
+		parent::__construct($params);
37
+	}
38 38
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/ResponseCluster.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@
 block discarded – undo
15 15
  */
16 16
 class ResponseCluster extends Common
17 17
 {
18
-    /**
19
-     * Cluster of addresses
20
-     */
21
-    public ?Cluster $cluster = null;
18
+	/**
19
+	 * Cluster of addresses
20
+	 */
21
+	public ?Cluster $cluster = null;
22 22
 
23
-    /**
24
-     * A number of the returned addresses.
25
-     * @example 1
26
-     */
27
-    public ?int $address_count = null;
23
+	/**
24
+	 * A number of the returned addresses.
25
+	 * @example 1
26
+	 */
27
+	public ?int $address_count = null;
28 28
 
29
-    public function __construct(?array $params = null)
30
-    {
31
-        if ($params !== null) {
32
-            foreach ($this as $key => $value) {
33
-                if (isset($params[$key])) {
34
-                    if ($key === 'cluster') {
35
-                        if (is_array($params[$key])) {
36
-                            $this->{$key} = new Cluster($params[$key]);
37
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof Cluster) {
38
-                            $this->{$key} = $params[$key];
39
-                        }
40
-                    } else {
41
-                        $this->{$key} = $params[$key];
42
-                    }
43
-                }
44
-            }
45
-        }
46
-    }
29
+	public function __construct(?array $params = null)
30
+	{
31
+		if ($params !== null) {
32
+			foreach ($this as $key => $value) {
33
+				if (isset($params[$key])) {
34
+					if ($key === 'cluster') {
35
+						if (is_array($params[$key])) {
36
+							$this->{$key} = new Cluster($params[$key]);
37
+						} elseif (is_object($params[$key]) && $params[$key] instanceof Cluster) {
38
+							$this->{$key} = $params[$key];
39
+						}
40
+					} else {
41
+						$this->{$key} = $params[$key];
42
+					}
43
+				}
44
+			}
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 
29 29
     public function __construct(?array $params = null)
30 30
     {
31
-        if ($params !== null) {
31
+        if ($params!==null) {
32 32
             foreach ($this as $key => $value) {
33 33
                 if (isset($params[$key])) {
34
-                    if ($key === 'cluster') {
34
+                    if ($key==='cluster') {
35 35
                         if (is_array($params[$key])) {
36 36
                             $this->{$key} = new Cluster($params[$key]);
37 37
                         } elseif (is_object($params[$key]) && $params[$key] instanceof Cluster) {
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/Cluster.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -13,35 +13,35 @@
 block discarded – undo
13 13
  */
14 14
 class Cluster extends Common
15 15
 {
16
-    /**
17
-     * Geohash
18
-     * @example 1mr8h4r9
19
-     */
20
-    public ?string $geohash = null;
16
+	/**
17
+	 * Geohash
18
+	 * @example 1mr8h4r9
19
+	 */
20
+	public ?string $geohash = null;
21 21
 
22
-    /**
23
-     * Latitude
24
-     * @example -60.456132888793945
25
-     */
26
-    public ?float $lat = null;
22
+	/**
23
+	 * Latitude
24
+	 * @example -60.456132888793945
25
+	 */
26
+	public ?float $lat = null;
27 27
 
28
-    /**
29
-     * Longitude
30
-     * @example -60.456132888793945
31
-     */
32
-    public ?float $lng = null;
28
+	/**
29
+	 * Longitude
30
+	 * @example -60.456132888793945
31
+	 */
32
+	public ?float $lng = null;
33 33
 
34
-    /**
35
-     * Boundary box, array of pairs of floats.
36
-     * @var float[][]
37
-     * @example [[52.294921875, 5.2294921875], [52.3388671875, 5.2734375]]
38
-     */
39
-    public ?array $bbox = null;
34
+	/**
35
+	 * Boundary box, array of pairs of floats.
36
+	 * @var float[][]
37
+	 * @example [[52.294921875, 5.2294921875], [52.3388671875, 5.2734375]]
38
+	 */
39
+	public ?array $bbox = null;
40 40
 
41
-    public function __construct(?array $params = null)
42
-    {
43
-        if ($params !== null) {
44
-            $this->fillFromArray($params);
45
-        }
46
-    }
41
+	public function __construct(?array $params = null)
42
+	{
43
+		if ($params !== null) {
44
+			$this->fillFromArray($params);
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/ScheduleItem.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
  */
14 14
 class ScheduleItem extends Common
15 15
 {
16
-    /**
17
-     * If true, the schedule is enabled.
18
-     */
19
-    public ?bool $enable = null;
16
+	/**
17
+	 * If true, the schedule is enabled.
18
+	 */
19
+	public ?bool $enable = null;
20 20
 
21
-    /**
22
-     * Schedule mode.
23
-     * @example 'monthly'
24
-     */
25
-    public ?string $mode = null;
21
+	/**
22
+	 * Schedule mode.
23
+	 * @example 'monthly'
24
+	 */
25
+	public ?string $mode = null;
26 26
 
27
-    /**
28
-     * Monthly properties.
29
-     * @example ['every' => 1]
30
-     */
31
-    public ?array $monthly = null;
27
+	/**
28
+	 * Monthly properties.
29
+	 * @example ['every' => 1]
30
+	 */
31
+	public ?array $monthly = null;
32 32
 
33
-    public function __construct(?array $params = null)
34
-    {
35
-        if ($params !== null) {
36
-            $this->fillFromArray($params);
37
-        }
38
-    }
33
+	public function __construct(?array $params = null)
34
+	{
35
+		if ($params !== null) {
36
+			$this->fillFromArray($params);
37
+		}
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/Address.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@
 block discarded – undo
14 14
  */
15 15
 class Address extends ResponseAddress
16 16
 {
17
-    /**
18
-     * @param array|string $params_or_address_1  - The route Address Line 1 or array of Address's values.
19
-     * @param float        $cached_lat           - A latitude of the contact's cached position.
20
-     * @param float        $cached_lng           - A longitude of the contact's cached position.
21
-     * @param string       $address_stop_type    - The contact's stop type. available types:
22
-     *                                             'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
23
-     *                                             'SERVICE', 'VISIT', 'DRIVEBY'
24
-     */
25
-    public function __construct(
26
-        $params_or_address_1,
27
-        ?float $cached_lat = null,
28
-        ?float $cached_lng = null,
29
-        ?string $address_stop_type = null
30
-    ) {
31
-        if (is_array($params_or_address_1) && isset($params_or_address_1['address_1'])
32
-            && isset($params_or_address_1['cached_lat']) && isset($params_or_address_1['cached_lng'])
33
-            && isset($params_or_address_1['address_stop_type'])
34
-        ) {
35
-            parent::__construct($params_or_address_1);
36
-        } elseif (is_string($params_or_address_1) && $params_or_address_1 != ""
37
-            && !is_null($cached_lat) && !is_null($cached_lng) && !is_null($address_stop_type)
38
-        ) {
39
-            $this->address_1 = $params_or_address_1;
40
-            $this->cached_lat = $cached_lat;
41
-            $this->cached_lng = $cached_lng;
42
-            $this->address_stop_type = $address_stop_type;
43
-        } else {
44
-            throw new ApiError('The fields address_1, cached_lat, cached_lng, address_stop_type are required.');
45
-        }
46
-    }
17
+	/**
18
+	 * @param array|string $params_or_address_1  - The route Address Line 1 or array of Address's values.
19
+	 * @param float        $cached_lat           - A latitude of the contact's cached position.
20
+	 * @param float        $cached_lng           - A longitude of the contact's cached position.
21
+	 * @param string       $address_stop_type    - The contact's stop type. available types:
22
+	 *                                             'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
23
+	 *                                             'SERVICE', 'VISIT', 'DRIVEBY'
24
+	 */
25
+	public function __construct(
26
+		$params_or_address_1,
27
+		?float $cached_lat = null,
28
+		?float $cached_lng = null,
29
+		?string $address_stop_type = null
30
+	) {
31
+		if (is_array($params_or_address_1) && isset($params_or_address_1['address_1'])
32
+			&& isset($params_or_address_1['cached_lat']) && isset($params_or_address_1['cached_lng'])
33
+			&& isset($params_or_address_1['address_stop_type'])
34
+		) {
35
+			parent::__construct($params_or_address_1);
36
+		} elseif (is_string($params_or_address_1) && $params_or_address_1 != ""
37
+			&& !is_null($cached_lat) && !is_null($cached_lng) && !is_null($address_stop_type)
38
+		) {
39
+			$this->address_1 = $params_or_address_1;
40
+			$this->cached_lat = $cached_lat;
41
+			$this->cached_lng = $cached_lng;
42
+			$this->address_stop_type = $address_stop_type;
43
+		} else {
44
+			throw new ApiError('The fields address_1, cached_lat, cached_lng, address_stop_type are required.');
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
             && isset($params_or_address_1['address_stop_type'])
34 34
         ) {
35 35
             parent::__construct($params_or_address_1);
36
-        } elseif (is_string($params_or_address_1) && $params_or_address_1 != ""
36
+        } elseif (is_string($params_or_address_1) && $params_or_address_1!=""
37 37
             && !is_null($cached_lat) && !is_null($cached_lng) && !is_null($address_stop_type)
38 38
         ) {
39 39
             $this->address_1 = $params_or_address_1;
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/StatusChecker.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@
 block discarded – undo
13 13
  */
14 14
 class StatusChecker extends Common
15 15
 {
16
-    /**
17
-     * HTTP code.
18
-     * @example 200, 202
19
-     */
20
-    public ?int $code = null;
21
-
22
-    /**
23
-     * Requested data if request was handled synchronously.
24
-     * @example ['status' => 1] - Successful operation
25
-     */
26
-    public ?array $data = null;
27
-
28
-    /**
29
-     * Path to the status checker if request was handled asynchronously.
30
-     */
31
-    public ?string $location = null;
32
-
33
-    /**
34
-     * Job Id to check status if request was handled asynchronously.
35
-     */
36
-    public ?string $x_job_id = null;
37
-
38
-    /**
39
-     * Job running time in seconds.
40
-     */
41
-    public ?string $x_r4m_async_job_running_time = null;
42
-
43
-    public function __construct(?array $params = null)
44
-    {
45
-        if ($params !== null) {
46
-            $this->fillFromArray($params);
47
-        }
48
-    }
16
+	/**
17
+	 * HTTP code.
18
+	 * @example 200, 202
19
+	 */
20
+	public ?int $code = null;
21
+
22
+	/**
23
+	 * Requested data if request was handled synchronously.
24
+	 * @example ['status' => 1] - Successful operation
25
+	 */
26
+	public ?array $data = null;
27
+
28
+	/**
29
+	 * Path to the status checker if request was handled asynchronously.
30
+	 */
31
+	public ?string $location = null;
32
+
33
+	/**
34
+	 * Job Id to check status if request was handled asynchronously.
35
+	 */
36
+	public ?string $x_job_id = null;
37
+
38
+	/**
39
+	 * Job running time in seconds.
40
+	 */
41
+	public ?string $x_r4m_async_job_running_time = null;
42
+
43
+	public function __construct(?array $params = null)
44
+	{
45
+		if ($params !== null) {
46
+			$this->fillFromArray($params);
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/AddressBook/ResponseAll.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -14,43 +14,43 @@
 block discarded – undo
14 14
  */
15 15
 class ResponseAll extends Common
16 16
 {
17
-    /**
18
-     * Array of ResponceAddresses.
19
-     * @var ResponceAddress[]
20
-     */
21
-    public ?array $results = null;
17
+	/**
18
+	 * Array of ResponceAddresses.
19
+	 * @var ResponceAddress[]
20
+	 */
21
+	public ?array $results = null;
22 22
 
23
-    /**
24
-     * Total quantity of ResponceAddresses that match the query.
25
-     * @example 1
26
-     */
27
-    public ?int $total = null;
23
+	/**
24
+	 * Total quantity of ResponceAddresses that match the query.
25
+	 * @example 1
26
+	 */
27
+	public ?int $total = null;
28 28
 
29
-    /**
30
-     * An array of valid fields name in results array.
31
-     * @var string[]
32
-     */
33
-    public ?array $fields = null;
29
+	/**
30
+	 * An array of valid fields name in results array.
31
+	 * @var string[]
32
+	 */
33
+	public ?array $fields = null;
34 34
 
35
-    public function __construct(?array $params = null)
36
-    {
37
-        if ($params !== null) {
38
-            foreach ($this as $key => $value) {
39
-                if (isset($params[$key])) {
40
-                    if ($key === 'results') {
41
-                        $this->{$key} = array();
42
-                        foreach ($params[$key] as $ra_key => $ra_value) {
43
-                            if (is_array($ra_value)) {
44
-                                array_push($this->{$key}, new ResponseAddress($ra_value));
45
-                            } elseif (is_object($ra_value) && $ra_value instanceof ResponseAddress) {
46
-                                array_push($this->{$key}, $ra_value);
47
-                            }
48
-                        }
49
-                    } else {
50
-                        $this->{$key} = $params[$key];
51
-                    }
52
-                }
53
-            }
54
-        }
55
-    }
35
+	public function __construct(?array $params = null)
36
+	{
37
+		if ($params !== null) {
38
+			foreach ($this as $key => $value) {
39
+				if (isset($params[$key])) {
40
+					if ($key === 'results') {
41
+						$this->{$key} = array();
42
+						foreach ($params[$key] as $ra_key => $ra_value) {
43
+							if (is_array($ra_value)) {
44
+								array_push($this->{$key}, new ResponseAddress($ra_value));
45
+							} elseif (is_object($ra_value) && $ra_value instanceof ResponseAddress) {
46
+								array_push($this->{$key}, $ra_value);
47
+							}
48
+						}
49
+					} else {
50
+						$this->{$key} = $params[$key];
51
+					}
52
+				}
53
+			}
54
+		}
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
 
35 35
     public function __construct(?array $params = null)
36 36
     {
37
-        if ($params !== null) {
37
+        if ($params!==null) {
38 38
             foreach ($this as $key => $value) {
39 39
                 if (isset($params[$key])) {
40
-                    if ($key === 'results') {
40
+                    if ($key==='results') {
41 41
                         $this->{$key} = array();
42 42
                         foreach ($params[$key] as $ra_key => $ra_value) {
43 43
                             if (is_array($ra_value)) {
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 3 patches
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -7,367 +7,367 @@
 block discarded – undo
7 7
 
8 8
 class Route4Me
9 9
 {
10
-    public static $apiKey;
11
-    public static $baseUrl = Endpoint::BASE_URL;
12
-
13
-    public static function setApiKey($apiKey)
14
-    {
15
-        self::$apiKey = $apiKey;
16
-    }
17
-
18
-    public static function getApiKey()
19
-    {
20
-        return self::$apiKey;
21
-    }
22
-
23
-    public static function setBaseUrl($baseUrl)
24
-    {
25
-        self::$baseUrl = $baseUrl;
26
-    }
27
-
28
-    public static function getBaseUrl()
29
-    {
30
-        return self::$baseUrl;
31
-    }
32
-
33
-    /**
34
-     * Make request with CURL
35
-     *
36
-     * @since 1.2.3 changed error handling
37
-     * @since 1.2.8 added $options['return_headers']
38
-     *
39
-     * @param array  $options
40
-     *   string url                        - HTTP URL.
41
-     *   string method                     - HTTP method.
42
-     *   string api_key                    - API key to access to route4me server.
43
-     *   array  query                      - Array of query parameters.
44
-     *   array  body                       - Array of body parameters.
45
-     *   string HTTPHEADER                 - Content type of body e.g.
46
-     *                                       'Content-Type: application/json'
47
-     *                                       'Content-Type: multipart/form-data'
48
-     *   array  HTTPHEADERS                - Array of headers.
49
-     *   string FILE                       - Path to uploading file.
50
-     *   array  return_headers             - Array of response headers to return as a result.
51
-     * @throws Exception\ApiError
52
-     */
53
-    public static function makeRequst($options)
54
-    {
55
-        $method = isset($options['method']) ? $options['method'] : 'GET';
56
-        $query = isset($options['query'])
57
-            ? array_filter($options['query'], function ($x) {
58
-                return !is_null($x);
59
-            }) : [];
60
-
61
-        $body = isset($options['body']) ? $options['body'] : null;
62
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
63
-        $headers = [
64
-            'User-Agent: Route4Me php-sdk',
65
-        ];
66
-
67
-        $return_headers = (isset($options['return_headers']) ? $options['return_headers'] : null);
68
-
69
-        if (isset($options['HTTPHEADER'])) {
70
-            $headers[] = $options['HTTPHEADER'];
71
-        }
72
-
73
-        if (isset($options['HTTPHEADERS'])) {
74
-            foreach ($options['HTTPHEADERS'] as $header) {
75
-                $headers[] = $header;
76
-            }
77
-        }
78
-
79
-        $ch = curl_init();
80
-
81
-        $url = isset($options['url'])
82
-            ? $options['url'] . '?' . http_build_query(array_merge(
83
-                $query,
84
-                ['api_key' => self::getApiKey()]
85
-            )) : '';
86
-
87
-        $baseUrl = self::getBaseUrl();
88
-
89
-        $curlOpts = [
90
-            CURLOPT_URL             => $baseUrl.$url,
91
-            CURLOPT_RETURNTRANSFER  => true,
92
-            CURLOPT_TIMEOUT         => 120,
93
-            CURLOPT_FOLLOWLOCATION  => true,
94
-            CURLOPT_SSL_VERIFYHOST  => false,
95
-            CURLOPT_SSL_VERIFYPEER  => false,
96
-            CURLOPT_HTTPHEADER      => $headers,
97
-        ];
98
-
99
-        curl_setopt_array($ch, $curlOpts);
100
-
101
-        // read response headers if need
102
-        $response_headers = [];
103
-        if ($return_headers) {
104
-            curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) {
105
-                $len = strlen($header);
106
-                $header = explode(':', $header, 2);
107
-                if (count($header) >= 2) {
108
-                    $response_headers[strtolower(trim($header[0]))] = trim($header[1]);
109
-                }
110
-                return $len;
111
-            });
112
-        }
113
-
114
-        if (null != $file) {
115
-            $cfile = new \CURLFile($file, '', '');
116
-            $body['strFilename']=$cfile;
117
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
118
-            curl_setopt($ch, CURLOPT_POST, true);
119
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
120
-        } else {
121
-            switch ($method) {
122
-                case 'DELETE':
123
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
124
-                    break;
125
-                case 'DELETEARRAY':
126
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
127
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
128
-                    break;
129
-                case 'PUT':
130
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
131
-                    break;
132
-                case 'POST':
133
-                    if (isset($body)) {
134
-                        $bodyData = json_encode($body);
135
-                        if (isset($options['HTTPHEADER'])) {
136
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
137
-                                $bodyData = $body;
138
-                            }
139
-                        }
140
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
141
-                    }
142
-                    break;
143
-                case 'ADD':
144
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
145
-                    break;
146
-                case 'PATCH':
147
-                    if (isset($body)) {
148
-                        $bodyData = json_encode($body);
149
-                        if (isset($options['HTTPHEADER'])) {
150
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
151
-                                $bodyData = $body;
152
-                            }
153
-                        }
154
-                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
155
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
156
-                    }
157
-                    break;
158
-            }
159
-
160
-            if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
161
-                if (isset($body)) {
162
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
163
-                }
164
-            }
165
-        }
166
-
167
-        $result = curl_exec($ch);
168
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
169
-        curl_close($ch);
170
-
171
-        $json = null;
172
-        if (strpos($result, '<?xml') > -1) {
173
-            $xml = simplexml_load_string($result);
174
-            $json = self::object2array($xml);
175
-        } else {
176
-            $json = json_decode($result, true);
177
-        }
178
-        if (200 == $code || 201 == $code || 202 == $code) {
179
-            if (isset($json['errors'])) {
180
-                throw new ApiError(implode(', ', $json['errors']), $code, $result);
181
-            } else {
182
-                // return response headers if they were asked for
183
-                if (count($response_headers) !== 0) {
184
-                    $res = [
185
-                        'code' => $code,
186
-                        'data' => $json
187
-                    ];
188
-                    foreach ($return_headers as $key => $value) {
189
-                        // most headers has char '-' but it is forbidden in PHP names replace it with '_'
190
-                        $res[strtolower(str_replace('-', '_', $value))] =
191
-                            (isset($response_headers[$value]) ? $response_headers[$value] : null);
192
-                    }
193
-                    return $res;
194
-                }
195
-                return $json;
196
-            }
197
-        } elseif (isset($code) && (!isset($result) || !$result)) {
198
-            throw new ApiError('', $code, $result);
199
-        } else {
200
-            if (isset($json['messages'])) {
201
-                $msg = '';
202
-                foreach ($json['messages'] as $key => $value) {
203
-                    if ($msg !== '') {
204
-                        $msg .= PHP_EOL;
205
-                    }
206
-                    $msg .= $key . ': ' . implode(', ', $value);
207
-                }
208
-                throw new ApiError($msg, $code, $result);
209
-            } elseif (isset($json['errors'])) {
210
-                $msg = '';
211
-                foreach ($json['errors'] as $key => $value) {
212
-                    if ($msg !== '') {
213
-                        $msg .= PHP_EOL;
214
-                    }
215
-                    $msg .= $value;
216
-                }
217
-                throw new ApiError($msg, $code, $result);
218
-            } else {
219
-                throw new ApiError($result, $code, $result);
220
-            }
221
-        }
222
-    }
223
-
224
-    /**
225
-     * @param $object: JSON object
226
-     */
227
-    public static function object2array($object)
228
-    {
229
-        return @json_decode(@json_encode($object), 1);
230
-    }
231
-
232
-    /**
233
-     * Prints on the screen main keys and values of the array.
234
-     *
235
-     * @param $results: object to be printed on the screen
236
-     * @param $deepPrinting: if true, object will be printed recursively
237
-     */
238
-    public static function simplePrint($results, $deepPrinting = null)
239
-    {
240
-        if (isset($results)) {
241
-            if (is_array($results)) {
242
-                foreach ($results as $key => $result) {
243
-                    if (is_array($result)) {
244
-                        foreach ($result as $key1 => $result1) {
245
-                            if (is_array($result1)) {
246
-                                if ($deepPrinting) {
247
-                                    echo "<br>$key1 ------><br>";
248
-                                    self::simplePrint($result1, true);
249
-                                    echo '------<br>';
250
-                                } else {
251
-                                    echo $key1.' --> '.'Array() <br>';
252
-                                }
253
-                            } else {
254
-                                if (is_object($result1)) {
255
-                                    if ($deepPrinting) {
256
-                                        echo "<br>$key1 ------><br>";
257
-                                        $oarray = (array) $result1;
258
-                                        self::simplePrint($oarray, true);
259
-                                        echo '------<br>';
260
-                                    } else {
261
-                                        echo $key1.' --> '.'Object <br>';
262
-                                    }
263
-                                } else {
264
-                                    if (!is_null($result1)) {
265
-                                        echo $key1.' --> '.$result1.'<br>';
266
-                                    }
267
-                                }
268
-                            }
269
-                        }
270
-                    } else {
271
-                        if (is_object($result)) {
272
-                            if ($deepPrinting) {
273
-                                echo "<br>$key ------><br>";
274
-                                $oarray = (array) $result;
275
-                                self::simplePrint($oarray, true);
276
-                                echo '------<br>';
277
-                            } else {
278
-                                echo $key.' --> '.'Object <br>';
279
-                            }
280
-                        } else {
281
-                            if (!is_null($result)) {
282
-                                echo $key.' --> '.$result.'<br>';
283
-                            }
284
-                        }
285
-                    }
286
-                    //echo "<br>";
287
-                }
288
-            }
289
-        }
290
-    }
291
-
292
-    /**
293
-     * Generates query or body parameters.
294
-     *
295
-     * @param $allFields: all known fields could be used for parameters generation
296
-     * @param $params: input parameters (array or object)
297
-     */
298
-    public static function generateRequestParameters($allFields, $params)
299
-    {
300
-        $generatedParams = [];
301
-
302
-        if (is_array($params)) {
303
-            foreach ($allFields as $field) {
304
-                if (isset($params[$field])) {
305
-                    $generatedParams[$field] = $params[$field];
306
-                }
307
-            }
308
-        } elseif (is_object($params)) {
309
-            foreach ($allFields as $field) {
310
-                if (isset($params->{$field})) {
311
-                    $generatedParams[$field] = $params->{$field};
312
-                }
313
-            }
314
-        }
315
-
316
-        return $generatedParams;
317
-    }
318
-
319
-    /**
320
-     * Returns an array of the object properties.
321
-     *
322
-     * @param $object: An object
323
-     * @param $exclude: array of the object parameters to be excluded from the returned array
324
-     */
325
-    public static function getObjectProperties($object, $exclude)
326
-    {
327
-        $objectParameters = [];
328
-
329
-        foreach (get_object_vars($object) as $key => $value) {
330
-            if (property_exists($object, $key)) {
331
-                if (!is_numeric(array_search($key, $exclude))) {
332
-                    array_push($objectParameters, $key);
333
-                }
334
-            }
335
-        }
336
-
337
-        return $objectParameters;
338
-    }
339
-
340
-    /**
341
-     * Returns url path generated from the array of the fields and parameters.
342
-     *
343
-     * @param $allFields; array of the paossible fields (parameter names)
344
-     * @param $params: input parameters (array or object)
345
-     */
346
-    public static function generateUrlPath($allFields, $params)
347
-    {
348
-        $generatedPath = '';
349
-
350
-        if (is_array($params)) {
351
-            foreach ($allFields as $field) {
352
-                if (isset($params[$field])) {
353
-                    $generatedPath .= $params[$field].'/';
354
-                }
355
-            }
356
-        } elseif (is_object($params)) {
357
-            foreach ($allFields as $field) {
358
-                if (isset($params->{$field})) {
359
-                    $generatedPath .= $params->{$field}.'/';
360
-                }
361
-            }
362
-        }
363
-
364
-        return $generatedPath;
365
-    }
366
-
367
-    public static function getFileRealPath($fileName)
368
-    {
369
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
370
-
371
-        return $rpath;
372
-    }
10
+	public static $apiKey;
11
+	public static $baseUrl = Endpoint::BASE_URL;
12
+
13
+	public static function setApiKey($apiKey)
14
+	{
15
+		self::$apiKey = $apiKey;
16
+	}
17
+
18
+	public static function getApiKey()
19
+	{
20
+		return self::$apiKey;
21
+	}
22
+
23
+	public static function setBaseUrl($baseUrl)
24
+	{
25
+		self::$baseUrl = $baseUrl;
26
+	}
27
+
28
+	public static function getBaseUrl()
29
+	{
30
+		return self::$baseUrl;
31
+	}
32
+
33
+	/**
34
+	 * Make request with CURL
35
+	 *
36
+	 * @since 1.2.3 changed error handling
37
+	 * @since 1.2.8 added $options['return_headers']
38
+	 *
39
+	 * @param array  $options
40
+	 *   string url                        - HTTP URL.
41
+	 *   string method                     - HTTP method.
42
+	 *   string api_key                    - API key to access to route4me server.
43
+	 *   array  query                      - Array of query parameters.
44
+	 *   array  body                       - Array of body parameters.
45
+	 *   string HTTPHEADER                 - Content type of body e.g.
46
+	 *                                       'Content-Type: application/json'
47
+	 *                                       'Content-Type: multipart/form-data'
48
+	 *   array  HTTPHEADERS                - Array of headers.
49
+	 *   string FILE                       - Path to uploading file.
50
+	 *   array  return_headers             - Array of response headers to return as a result.
51
+	 * @throws Exception\ApiError
52
+	 */
53
+	public static function makeRequst($options)
54
+	{
55
+		$method = isset($options['method']) ? $options['method'] : 'GET';
56
+		$query = isset($options['query'])
57
+			? array_filter($options['query'], function ($x) {
58
+				return !is_null($x);
59
+			}) : [];
60
+
61
+		$body = isset($options['body']) ? $options['body'] : null;
62
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
63
+		$headers = [
64
+			'User-Agent: Route4Me php-sdk',
65
+		];
66
+
67
+		$return_headers = (isset($options['return_headers']) ? $options['return_headers'] : null);
68
+
69
+		if (isset($options['HTTPHEADER'])) {
70
+			$headers[] = $options['HTTPHEADER'];
71
+		}
72
+
73
+		if (isset($options['HTTPHEADERS'])) {
74
+			foreach ($options['HTTPHEADERS'] as $header) {
75
+				$headers[] = $header;
76
+			}
77
+		}
78
+
79
+		$ch = curl_init();
80
+
81
+		$url = isset($options['url'])
82
+			? $options['url'] . '?' . http_build_query(array_merge(
83
+				$query,
84
+				['api_key' => self::getApiKey()]
85
+			)) : '';
86
+
87
+		$baseUrl = self::getBaseUrl();
88
+
89
+		$curlOpts = [
90
+			CURLOPT_URL             => $baseUrl.$url,
91
+			CURLOPT_RETURNTRANSFER  => true,
92
+			CURLOPT_TIMEOUT         => 120,
93
+			CURLOPT_FOLLOWLOCATION  => true,
94
+			CURLOPT_SSL_VERIFYHOST  => false,
95
+			CURLOPT_SSL_VERIFYPEER  => false,
96
+			CURLOPT_HTTPHEADER      => $headers,
97
+		];
98
+
99
+		curl_setopt_array($ch, $curlOpts);
100
+
101
+		// read response headers if need
102
+		$response_headers = [];
103
+		if ($return_headers) {
104
+			curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) {
105
+				$len = strlen($header);
106
+				$header = explode(':', $header, 2);
107
+				if (count($header) >= 2) {
108
+					$response_headers[strtolower(trim($header[0]))] = trim($header[1]);
109
+				}
110
+				return $len;
111
+			});
112
+		}
113
+
114
+		if (null != $file) {
115
+			$cfile = new \CURLFile($file, '', '');
116
+			$body['strFilename']=$cfile;
117
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
118
+			curl_setopt($ch, CURLOPT_POST, true);
119
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
120
+		} else {
121
+			switch ($method) {
122
+				case 'DELETE':
123
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
124
+					break;
125
+				case 'DELETEARRAY':
126
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
127
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
128
+					break;
129
+				case 'PUT':
130
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
131
+					break;
132
+				case 'POST':
133
+					if (isset($body)) {
134
+						$bodyData = json_encode($body);
135
+						if (isset($options['HTTPHEADER'])) {
136
+							if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
137
+								$bodyData = $body;
138
+							}
139
+						}
140
+						curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
141
+					}
142
+					break;
143
+				case 'ADD':
144
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
145
+					break;
146
+				case 'PATCH':
147
+					if (isset($body)) {
148
+						$bodyData = json_encode($body);
149
+						if (isset($options['HTTPHEADER'])) {
150
+							if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
151
+								$bodyData = $body;
152
+							}
153
+						}
154
+						curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
155
+						curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
156
+					}
157
+					break;
158
+			}
159
+
160
+			if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
161
+				if (isset($body)) {
162
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
163
+				}
164
+			}
165
+		}
166
+
167
+		$result = curl_exec($ch);
168
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
169
+		curl_close($ch);
170
+
171
+		$json = null;
172
+		if (strpos($result, '<?xml') > -1) {
173
+			$xml = simplexml_load_string($result);
174
+			$json = self::object2array($xml);
175
+		} else {
176
+			$json = json_decode($result, true);
177
+		}
178
+		if (200 == $code || 201 == $code || 202 == $code) {
179
+			if (isset($json['errors'])) {
180
+				throw new ApiError(implode(', ', $json['errors']), $code, $result);
181
+			} else {
182
+				// return response headers if they were asked for
183
+				if (count($response_headers) !== 0) {
184
+					$res = [
185
+						'code' => $code,
186
+						'data' => $json
187
+					];
188
+					foreach ($return_headers as $key => $value) {
189
+						// most headers has char '-' but it is forbidden in PHP names replace it with '_'
190
+						$res[strtolower(str_replace('-', '_', $value))] =
191
+							(isset($response_headers[$value]) ? $response_headers[$value] : null);
192
+					}
193
+					return $res;
194
+				}
195
+				return $json;
196
+			}
197
+		} elseif (isset($code) && (!isset($result) || !$result)) {
198
+			throw new ApiError('', $code, $result);
199
+		} else {
200
+			if (isset($json['messages'])) {
201
+				$msg = '';
202
+				foreach ($json['messages'] as $key => $value) {
203
+					if ($msg !== '') {
204
+						$msg .= PHP_EOL;
205
+					}
206
+					$msg .= $key . ': ' . implode(', ', $value);
207
+				}
208
+				throw new ApiError($msg, $code, $result);
209
+			} elseif (isset($json['errors'])) {
210
+				$msg = '';
211
+				foreach ($json['errors'] as $key => $value) {
212
+					if ($msg !== '') {
213
+						$msg .= PHP_EOL;
214
+					}
215
+					$msg .= $value;
216
+				}
217
+				throw new ApiError($msg, $code, $result);
218
+			} else {
219
+				throw new ApiError($result, $code, $result);
220
+			}
221
+		}
222
+	}
223
+
224
+	/**
225
+	 * @param $object: JSON object
226
+	 */
227
+	public static function object2array($object)
228
+	{
229
+		return @json_decode(@json_encode($object), 1);
230
+	}
231
+
232
+	/**
233
+	 * Prints on the screen main keys and values of the array.
234
+	 *
235
+	 * @param $results: object to be printed on the screen
236
+	 * @param $deepPrinting: if true, object will be printed recursively
237
+	 */
238
+	public static function simplePrint($results, $deepPrinting = null)
239
+	{
240
+		if (isset($results)) {
241
+			if (is_array($results)) {
242
+				foreach ($results as $key => $result) {
243
+					if (is_array($result)) {
244
+						foreach ($result as $key1 => $result1) {
245
+							if (is_array($result1)) {
246
+								if ($deepPrinting) {
247
+									echo "<br>$key1 ------><br>";
248
+									self::simplePrint($result1, true);
249
+									echo '------<br>';
250
+								} else {
251
+									echo $key1.' --> '.'Array() <br>';
252
+								}
253
+							} else {
254
+								if (is_object($result1)) {
255
+									if ($deepPrinting) {
256
+										echo "<br>$key1 ------><br>";
257
+										$oarray = (array) $result1;
258
+										self::simplePrint($oarray, true);
259
+										echo '------<br>';
260
+									} else {
261
+										echo $key1.' --> '.'Object <br>';
262
+									}
263
+								} else {
264
+									if (!is_null($result1)) {
265
+										echo $key1.' --> '.$result1.'<br>';
266
+									}
267
+								}
268
+							}
269
+						}
270
+					} else {
271
+						if (is_object($result)) {
272
+							if ($deepPrinting) {
273
+								echo "<br>$key ------><br>";
274
+								$oarray = (array) $result;
275
+								self::simplePrint($oarray, true);
276
+								echo '------<br>';
277
+							} else {
278
+								echo $key.' --> '.'Object <br>';
279
+							}
280
+						} else {
281
+							if (!is_null($result)) {
282
+								echo $key.' --> '.$result.'<br>';
283
+							}
284
+						}
285
+					}
286
+					//echo "<br>";
287
+				}
288
+			}
289
+		}
290
+	}
291
+
292
+	/**
293
+	 * Generates query or body parameters.
294
+	 *
295
+	 * @param $allFields: all known fields could be used for parameters generation
296
+	 * @param $params: input parameters (array or object)
297
+	 */
298
+	public static function generateRequestParameters($allFields, $params)
299
+	{
300
+		$generatedParams = [];
301
+
302
+		if (is_array($params)) {
303
+			foreach ($allFields as $field) {
304
+				if (isset($params[$field])) {
305
+					$generatedParams[$field] = $params[$field];
306
+				}
307
+			}
308
+		} elseif (is_object($params)) {
309
+			foreach ($allFields as $field) {
310
+				if (isset($params->{$field})) {
311
+					$generatedParams[$field] = $params->{$field};
312
+				}
313
+			}
314
+		}
315
+
316
+		return $generatedParams;
317
+	}
318
+
319
+	/**
320
+	 * Returns an array of the object properties.
321
+	 *
322
+	 * @param $object: An object
323
+	 * @param $exclude: array of the object parameters to be excluded from the returned array
324
+	 */
325
+	public static function getObjectProperties($object, $exclude)
326
+	{
327
+		$objectParameters = [];
328
+
329
+		foreach (get_object_vars($object) as $key => $value) {
330
+			if (property_exists($object, $key)) {
331
+				if (!is_numeric(array_search($key, $exclude))) {
332
+					array_push($objectParameters, $key);
333
+				}
334
+			}
335
+		}
336
+
337
+		return $objectParameters;
338
+	}
339
+
340
+	/**
341
+	 * Returns url path generated from the array of the fields and parameters.
342
+	 *
343
+	 * @param $allFields; array of the paossible fields (parameter names)
344
+	 * @param $params: input parameters (array or object)
345
+	 */
346
+	public static function generateUrlPath($allFields, $params)
347
+	{
348
+		$generatedPath = '';
349
+
350
+		if (is_array($params)) {
351
+			foreach ($allFields as $field) {
352
+				if (isset($params[$field])) {
353
+					$generatedPath .= $params[$field].'/';
354
+				}
355
+			}
356
+		} elseif (is_object($params)) {
357
+			foreach ($allFields as $field) {
358
+				if (isset($params->{$field})) {
359
+					$generatedPath .= $params->{$field}.'/';
360
+				}
361
+			}
362
+		}
363
+
364
+		return $generatedPath;
365
+	}
366
+
367
+	public static function getFileRealPath($fileName)
368
+	{
369
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
370
+
371
+		return $rpath;
372
+	}
373 373
 }
Please login to merge, or discard this patch.
Switch Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -119,42 +119,42 @@
 block discarded – undo
119 119
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
120 120
         } else {
121 121
             switch ($method) {
122
-                case 'DELETE':
123
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
124
-                    break;
125
-                case 'DELETEARRAY':
126
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
127
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
128
-                    break;
129
-                case 'PUT':
130
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
131
-                    break;
132
-                case 'POST':
133
-                    if (isset($body)) {
134
-                        $bodyData = json_encode($body);
135
-                        if (isset($options['HTTPHEADER'])) {
136
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
137
-                                $bodyData = $body;
138
-                            }
122
+            case 'DELETE':
123
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
124
+                break;
125
+            case 'DELETEARRAY':
126
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
127
+                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
128
+                break;
129
+            case 'PUT':
130
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
131
+                break;
132
+            case 'POST':
133
+                if (isset($body)) {
134
+                    $bodyData = json_encode($body);
135
+                    if (isset($options['HTTPHEADER'])) {
136
+                        if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
137
+                            $bodyData = $body;
139 138
                         }
140
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
141 139
                     }
142
-                    break;
143
-                case 'ADD':
144
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
145
-                    break;
146
-                case 'PATCH':
147
-                    if (isset($body)) {
148
-                        $bodyData = json_encode($body);
149
-                        if (isset($options['HTTPHEADER'])) {
150
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
151
-                                $bodyData = $body;
152
-                            }
140
+                    curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
141
+                }
142
+                break;
143
+            case 'ADD':
144
+                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
145
+                break;
146
+            case 'PATCH':
147
+                if (isset($body)) {
148
+                    $bodyData = json_encode($body);
149
+                    if (isset($options['HTTPHEADER'])) {
150
+                        if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
151
+                            $bodyData = $body;
153 152
                         }
154
-                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
155
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
156 153
                     }
157
-                    break;
154
+                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
155
+                    curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
156
+                }
157
+                break;
158 158
             }
159 159
 
160 160
             if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $method = isset($options['method']) ? $options['method'] : 'GET';
56 56
         $query = isset($options['query'])
57
-            ? array_filter($options['query'], function ($x) {
57
+            ? array_filter($options['query'], function($x) {
58 58
                 return !is_null($x);
59 59
             }) : [];
60 60
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $ch = curl_init();
80 80
 
81 81
         $url = isset($options['url'])
82
-            ? $options['url'] . '?' . http_build_query(array_merge(
82
+            ? $options['url'].'?'.http_build_query(array_merge(
83 83
                 $query,
84 84
                 ['api_key' => self::getApiKey()]
85 85
             )) : '';
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
         // read response headers if need
102 102
         $response_headers = [];
103 103
         if ($return_headers) {
104
-            curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$response_headers) {
104
+            curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$response_headers) {
105 105
                 $len = strlen($header);
106 106
                 $header = explode(':', $header, 2);
107
-                if (count($header) >= 2) {
107
+                if (count($header)>=2) {
108 108
                     $response_headers[strtolower(trim($header[0]))] = trim($header[1]);
109 109
                 }
110 110
                 return $len;
111 111
             });
112 112
         }
113 113
 
114
-        if (null != $file) {
114
+        if (null!=$file) {
115 115
             $cfile = new \CURLFile($file, '', '');
116
-            $body['strFilename']=$cfile;
116
+            $body['strFilename'] = $cfile;
117 117
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
118 118
             curl_setopt($ch, CURLOPT_POST, true);
119 119
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                     if (isset($body)) {
134 134
                         $bodyData = json_encode($body);
135 135
                         if (isset($options['HTTPHEADER'])) {
136
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
136
+                            if (strpos($options['HTTPHEADER'], 'multipart/form-data')>0) {
137 137
                                 $bodyData = $body;
138 138
                             }
139 139
                         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                     if (isset($body)) {
148 148
                         $bodyData = json_encode($body);
149 149
                         if (isset($options['HTTPHEADER'])) {
150
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
150
+                            if (strpos($options['HTTPHEADER'], 'multipart/form-data')>0) {
151 151
                                 $bodyData = $body;
152 152
                             }
153 153
                         }
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
         curl_close($ch);
170 170
 
171 171
         $json = null;
172
-        if (strpos($result, '<?xml') > -1) {
172
+        if (strpos($result, '<?xml')>-1) {
173 173
             $xml = simplexml_load_string($result);
174 174
             $json = self::object2array($xml);
175 175
         } else {
176 176
             $json = json_decode($result, true);
177 177
         }
178
-        if (200 == $code || 201 == $code || 202 == $code) {
178
+        if (200==$code || 201==$code || 202==$code) {
179 179
             if (isset($json['errors'])) {
180 180
                 throw new ApiError(implode(', ', $json['errors']), $code, $result);
181 181
             } else {
182 182
                 // return response headers if they were asked for
183
-                if (count($response_headers) !== 0) {
183
+                if (count($response_headers)!==0) {
184 184
                     $res = [
185 185
                         'code' => $code,
186 186
                         'data' => $json
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
             if (isset($json['messages'])) {
201 201
                 $msg = '';
202 202
                 foreach ($json['messages'] as $key => $value) {
203
-                    if ($msg !== '') {
203
+                    if ($msg!=='') {
204 204
                         $msg .= PHP_EOL;
205 205
                     }
206
-                    $msg .= $key . ': ' . implode(', ', $value);
206
+                    $msg .= $key.': '.implode(', ', $value);
207 207
                 }
208 208
                 throw new ApiError($msg, $code, $result);
209 209
             } elseif (isset($json['errors'])) {
210 210
                 $msg = '';
211 211
                 foreach ($json['errors'] as $key => $value) {
212
-                    if ($msg !== '') {
212
+                    if ($msg!=='') {
213 213
                         $msg .= PHP_EOL;
214 214
                     }
215 215
                     $msg .= $value;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                                 if (is_object($result1)) {
255 255
                                     if ($deepPrinting) {
256 256
                                         echo "<br>$key1 ------><br>";
257
-                                        $oarray = (array) $result1;
257
+                                        $oarray = (array)$result1;
258 258
                                         self::simplePrint($oarray, true);
259 259
                                         echo '------<br>';
260 260
                                     } else {
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                         if (is_object($result)) {
272 272
                             if ($deepPrinting) {
273 273
                                 echo "<br>$key ------><br>";
274
-                                $oarray = (array) $result;
274
+                                $oarray = (array)$result;
275 275
                                 self::simplePrint($oarray, true);
276 276
                                 echo '------<br>';
277 277
                             } else {
Please login to merge, or discard this patch.