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.
Passed
Push — master ( ba89cf...799599 )
by Oleg
02:27
created

AddressBookLocation::getAddressBookLocations()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 1
nop 1
dl 13
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
namespace Route4Me;
3
4
use Route4Me\Common;
5
use Route4Me\Enum\Endpoint;
6
7
class AddressBookLocation extends Common
8
{
9
    public $address_id;
10
    public $address_group;
11
    public $address_alias;
12
    public $address_1;
13
    public $address_2;
14
    public $first_name;
15
    public $last_name;
16
    public $address_email;
17
    public $address_phone_number;
18
    public $address_city;
19
    public $address_state_id;
20
    public $address_country_id;
21
    public $address_zip;
22
    public $cached_lat;
23
    public $cached_lng;
24
    public $curbside_lat;
25
    public $curbside_lng;
26
    public $color;
27
    public $address_custom_data;
28
    public $schedule;
29
    
30
    public $created_timestamp;
31
    public $member_id;
32
    public $schedule_blacklist;
33
    public $in_route_count;
34
    public $last_visited_timestamp;
35
    public $last_routed_timestamp;
36
    public $local_time_window_start;
37
    public $local_time_window_end;
38
    public $local_time_window_start_2;
39
    public $local_time_window_end_2;
40
    public $service_time;
41
    public $local_timezone_string;
42
    public $address_icon;
43
    public $address_stop_type;
44
    public $address_cube;
45
    public $address_pieces;
46
    public $address_reference_no;
47
    public $address_revenue;
48
    public $address_weight;
49
    public $address_priority;
50
    public $address_customer_po;
51
    
52
    public static function fromArray(array $params)
53
    {
54
        $addressbooklocation = new AddressBookLocation();
55
        
56
        foreach ($params as $key => $value) {
57
            if (property_exists($addressbooklocation, $key)) {
58
                $addressbooklocation->{$key} = $value;
59
            }
60
        }
61
        
62
        return $addressbooklocation;
63
    }
64
    
65 View Code Duplication
    public static function getAddressBookLocation($addressId)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
66
    {
67
        $ablocations = Route4Me::makeRequst(array(
68
            'url'    => Endpoint::ADDRESS_BOOK_V4,
69
            'method' => 'GET',
70
            'query'  => array(
71
                'query' => $addressId,
72
                'limit' => 30
73
            )
74
        ));
75
76
        return $ablocations;
77
    }
78
    
79 View Code Duplication
    public static function searchRoutedLocation($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
80
    {
81
        $result = Route4Me::makeRequst(array(
82
            'url'    => Endpoint::ADDRESS_BOOK_V4,
83
            'method' => 'GET',
84
            'query'  => array(
85
                'display' => isset($params['display']) ? $params['display'] : null,
86
                'query'   => isset($params['query']) ? $params['query'] : null,
87
                'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
                'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
                'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
            )
91
        ));
92
93
        return $result;
94
    }
95
    
96 View Code Duplication
    public static function getAddressBookLocations($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
97
    {
98
        $ablocations = Route4Me::makeRequst(array(
99
            'url'    => Endpoint::ADDRESS_BOOK_V4,
100
            'method' => 'GET',
101
            'query'  => array(
102
                'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
                'offset' => isset($params['offset']) ? $params['offset'] : null,
104
            )
105
        ));
106
107
        return $ablocations;
108
    }
109
    
110
    public static function getAddressBookLocationsByIDs($ids)
111
    {
112
        $ablocations = Route4Me::makeRequst(array(
113
            'url'    => Endpoint::ADDRESS_BOOK_V4,
114
            'method' => 'GET',
115
            'query'  => array(
116
                'address_id' => $ids
117
            )
118
        ));
119
120
        return $ablocations;
121
    }
122
    
123
    public static function getRandomAddressBookLocation($params)
124
    {
125
        $ablocations = Route4Me::makeRequst(array(
126
            'url'    => Endpoint::ADDRESS_BOOK_V4,
127
            'method' => 'GET',
128
            'query'  => array(
129
                'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
                'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
            )
132
        ));
133
        
134
        if (isset($ablocations["results"])) {
135
            $locationsSize = sizeof($ablocations["results"]);
136
            
137
            if ($locationsSize>0) {
138
                $randomLocationIndex = rand(0, $locationsSize - 1);
139
                return $ablocations["results"][$randomLocationIndex];
140
            } 
141
        } 
142
143
        return null;
144
    }
145
    
146
    /**
147
     * @param AddressBookLocation $params
148
    */
149 View Code Duplication
    public static function addAdressBookLocation($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
150
    {
151
        $body = array();
152
        $abLocations = new AddressBookLocation();
153
        
154
        foreach ($params as $key => $value) {
0 ignored issues
show
Bug introduced by
The expression $params of type object<Route4Me\AddressBookLocation> is not traversable.
Loading history...
155
            if ($key=="address_id") {
156
                continue;
157
            }
158
            
159
            if (property_exists($abLocations, $key)) {
160
                if (isset($params->{$key})) {
161
                    $body[$key] = $params->{$key};
162
                } 
163
            }
164
        }
165
        
166
        $response = Route4Me::makeRequst(array(
167
            'url'    => Endpoint::ADDRESS_BOOK_V4,
168
            'method' => 'POST',
169
            'body'   => $body
170
        ));
171
172
        return $response;
173
    }
174
    
175 View Code Duplication
    public function deleteAdressBookLocation($address_ids)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
176
    {
177
        $result = Route4Me::makeRequst(array(
178
            'url'    => Endpoint::ADDRESS_BOOK_V4,
179
            'method' => 'DELETEARRAY',
180
            'query'  => array(
181
                'address_ids' => $address_ids
182
            )
183
        ));
184
185
        return $result;
186
    }
187
    
188 View Code Duplication
    public function updateAdressBookLocation($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
189
    {
190
        $body = array();
191
        $abLocations = new AddressBookLocation();
192
        
193
        foreach ($params as $key => $value) {
194
            if (property_exists($abLocations, $key)) {
195
                if (isset($params->{$key})) {
196
                    $body[$key] = $params->{$key};
197
                } 
198
            }
199
        }
200
201
        $response = Route4Me::makeRequst(array(
202
            'url'    => Endpoint::ADDRESS_BOOK_V4,
203
            'method' => 'PUT',
204
            'body'   => $body,
205
        ));
206
207
        return $response;
208
    }
209
        
210 View Code Duplication
    public static function get($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
211
    {
212
        $ablocations = Route4Me::makeRequst(array(
213
            'url'    => Endpoint::ADDRESS_BOOK_V4,
214
            'method' => 'ADD',
215
            'query'  => array(
216
                'first_name' => isset($params->first_name) ? $params->first_name : null,
217
                'address_1'  => isset($params->address_1) ? $params->address_1 : null,
218
                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
219
                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
220
            )
221
        ));
222
223
        return $ablocations;
224
    }
225
    
226
    public static function validateScheduleMode($scheduleMode)
227
    {
228
        $schedMmodes = array("daily", "weekly", "monthly", "annually");
229
        
230
        if (in_array($scheduleMode, $schedMmodes)) {
231
            return TRUE; 
232
        } else {
233
            return FALSE;
234
        }
235
    }
236
    
237
    public static function validateScheduleEnable($scheduleEnabled)
238
    {
239
        $schedEnables = array(TRUE, FALSE);
240
        
241
        if (in_array($scheduleEnabled, $schedEnables)) {
242
            return TRUE;
243
        } else {
244
            return FALSE;
245
        }
246
    }
247
    
248
    public static function validateScheduleEvery($scheduleEvery)
249
    {
250
        if (is_numeric($scheduleEvery)) {
251
            return TRUE;
252
        } else {
253
            return FALSE;
254
        }
255
    }
256
    
257 View Code Duplication
    public static function validateScheduleWeekDays($scheduleWeekDays)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
258
    {
259
        $weekdays = explode(',', $scheduleWeekDays);
260
        
261
        if (sizeof($weekdays)<1) return FALSE;
262
        
263
        $isValid = TRUE;
264
        
265
        for ($i=0; $i<sizeof($weekdays); $i++) { 
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
266
            if (is_numeric($weekdays[$i])) {
267
                $wday = intval($weekdays[$i]);
268
                if ($wday<1 || $wday>7) $isValid = FALSE;
269
            } else {
270
                $isValid = FALSE;
271
            }
272
        }
273
        
274
        return $isValid;
275
    }
276
    
277
    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
278
    {
279
        $schedMonthlyMmodes = array("dates", "nth");
280
        
281
        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
282
            return TRUE;
283
        } else {
284
            return FALSE;
285
        }
286
    }
287
    
288 View Code Duplication
    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
289
    {
290
        $monthlyDates = explode(',', $scheduleMonthlyDates);
291
        
292
        if (sizeof($monthlyDates) <1) return FALSE;
293
        
294
        $isValid = TRUE;
295
        
296
        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
297
            if (is_numeric($monthlyDates[$i])) {
298
                $mday = intval($monthlyDates[$i]);
299
                if ($mday <1 || $mday > 31) $isValid = FALSE;
300
            } else {
301
                $isValid = FALSE;
302
            }
303
        }
304
305
        return $isValid;
306
    }
307
    
308
    public static function validateScheduleNthN($scheduleNthN)
309
    {
310
        if (!is_numeric($scheduleNthN)) return FALSE;
311
        
312
        $schedNthNs = array(1, 2, 3, 4, 5, -1);
313
        
314
        if (in_array($scheduleNthN, $schedNthNs)) {
315
            return TRUE;
316
        } else {
317
            return FALSE;
318
        }
319
    }
320
    
321
    public static function validateScheduleNthWhat($scheduleNthWhat)
322
    {
323
        if (!is_numeric($scheduleNthWhat)) return FALSE;
324
        
325
        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
326
        
327
        if (in_array($scheduleNthWhat, $schedNthWhats)) {
328
            return TRUE;
329
        } else {
330
            return FALSE;
331
        }
332
    }
333
    
334
    /* Function adds the locations (with/without schedule) from the CSV file. 
335
     * $csvFileHandle - a file handler.
336
     * Returns array $results which contains two arrays: fail and succes.
337
     */
338
    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
339
    {
340
        $max_line_length = 512;
341
        $delemietr = ',';
342
        
343
        $results = array();
344
        $results['fail'] = array();
345
        $results['success'] = array();
346
        
347
        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
348
        
349
        $addressBookFields = array("cached_lat","cached_lng","curbside_lat","curbside_lng","address_alias","address_1","address_2","address_city",
350
                "address_state_id","address_zip","address_phone_number","schedule","address_group","first_name","last_name","local_time_window_start",
351
                "local_time_window_end","local_time_window_start_2","local_time_window_end_2","address_email","address_country_id","address_custom_data",
352
                "schedule_blacklist","service_time","local_timezone_string","color","address_icon","address_stop_type","address_cube","address_pieces",
353
                "address_reference_no","address_revenue","address_weight","address_priority","address_customer_po");
354
355
        if (empty($columns)) {
356
            array_push($results['fail'], 'Empty CSV table');
357
            return ($results);
358
        }
359
360
        $iRow = 1;
361
        
362
        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
363
            if ($rows[$locationsFieldsMapping['cached_lat']] 
364
                  && $rows[$locationsFieldsMapping['cached_lng']] 
365
                  && $rows[$locationsFieldsMapping['address_1']] 
366
                  && array(null)!==$rows) {
367
                $curSchedule = "";
0 ignored issues
show
Unused Code introduced by
$curSchedule is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
368
                $mode = "";
369
                
370 View Code Duplication
                if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
371
                    if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
372
                        $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
373
                        $mode = $rows[$locationsFieldsMapping['schedule_mode']];
374
                    } else {
375
                        array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
376
                        $curSchedule = "";
377
                    }
378
                } else {
379
                    array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
380
                    $curSchedule = "";
381
                }
382
                
383
                if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
384
                    if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
385
                        $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
386
                    } else {
387
                        array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
388
                        $curSchedule = "";
389
                    }
390
                }
391
                
392
                if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
393
                    if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
394
                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
395
                        if ($mode == 'daily') {
396
                            $curSchedule = trim($curSchedule,',');
397
                            $curSchedule.='}';
398
                        }
399
                    } else {
400
                        array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
401
                        $curSchedule = ""; 
402
                    }
403
                }
404
                
405
                if ($mode!='daily') {
406
                    switch ($mode) {
407
                        case 'weekly':
408 View Code Duplication
                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
409
                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
410
                                     $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
411
                                } else {
412
                                    array_push($results['fail'], "$iRow --> Wrong weekdays"); 
413
                                    $curSchedule = "";
414
                                }
415
                            } else {
416
                                array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
417
                                $curSchedule = "";
418
                            }
419
                            break;
420
                        case 'monthly':
421
                            $monthlyMode = "";
422 View Code Duplication
                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
423
                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
424
                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
425
                                     $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
426
                                } else {
427
                                    array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
428
                                    $curSchedule = "";
429
                                }
430
                            } else {
431
                                array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
432
                                $curSchedule = "";
433
                            }
434
                            
435
                            if ($monthlyMode != "") {
436
                                switch ($monthlyMode) {
437
                                    case 'dates':
438
                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
439
                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
440
                                                 $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
441
                                            } else {
442
                                                array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
443
                                                $curSchedule = "";
444
                                            }
445
                                        }
446
                                        break;
447
                                    case 'nth':
448 View Code Duplication
                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
449
                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
450
                                                 $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
451
                                            } else {
452
                                                array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
453
                                                $curSchedule = "";
454
                                            }
455
                                        } else {
456
                                            array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
457
                                            $curSchedule = "";
458
                                        }
459
                                        
460 View Code Duplication
                                        if ($curSchedule != "") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
461
                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
462
                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
463
                                                     $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
464
                                                } else {
465
                                                    array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
466
                                                    $curSchedule = "";
467
                                                }
468
                                            } else {
469
                                                array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
470
                                                $curSchedule = "";
471
                                            }
472
                                        }
473
                                        break;
474
                                }
475
                            }
476
                            break;
477
                        default:
478
                            $curSchedule = "";
479
                            break;
480
                    }
481
                }
482
483
                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
484
                    $iRow++; 
485
                    continue;
486
                }
487
                
488
                $curSchedule = strtolower($curSchedule);
489
                
490
                $curSchedule = '[{'.$curSchedule.'}]';
491
492
                $oSchedule = json_decode($curSchedule,TRUE);
0 ignored issues
show
Unused Code introduced by
$oSchedule is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
493
                
494
                $parametersArray = array();
495
                
496
                foreach ($addressBookFields as $addressBookField) {
497
                    if (isset($locationsFieldsMapping[$addressBookField])) {
498
                        $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]];
499
                    }
500
                }
501
                
502
                $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray);
503
                
504
                $abContacts = new AddressBookLocation();
505
506
                $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
507
                
508
                array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
509
            }
510
        }
511
512
        return $results;
513
    }
514
 }
515