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 ( 5793f9...e93048 )
by Oleg
04:32
created

AddressBookLocation::addAdressBookLocation()   D

Complexity

Conditions 37
Paths 1

Size

Total Lines 47
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 37
eloc 42
nc 1
nop 1
dl 0
loc 47
rs 4.6475
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 6 and the first side effect is on line 278.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
	namespace Route4Me;
3
	
4
	use Route4Me\Common;
5
	
6
	class AddressBookLocation extends Common
7
	{
8
		static public $apiUrl = '/api.v4/address_book.php';
9
		static public $apiUrl00 = '/api/address_book/modify_contact.php';
10
		
11
		public $address_id;
12
		public $address_group;
13
		public $address_alias;
14
		public $address_1;
15
		public $address_2;
16
		public $first_name;
17
		public $last_name;
18
		public $address_email;
19
		public $address_phone_number;
20
		public $address_city;
21
		public $address_state_id;
22
		public $address_country_id;
23
		public $address_zip;
24
		public $cached_lat;
25
		public $cached_lng;
26
        public $curbside_lat;
27
        public $curbside_lng;
28
		public $color;
29
        public $address_custom_data;
30
        public $schedule;
31
		
32
		//public $offset;
33
		//public $limit;
34
		
35
		public function __construct () {  }
36
		
37
		public static function fromArray(array $params) {
38
			$addressbooklocation = new AddressBookLocation();
39
	        foreach($params as $key => $value) {
40
	            if (property_exists($addressbooklocation, $key)) {
41
	                $addressbooklocation->{$key} = $value;
42
	            }
43
			}
44
			
45
			return $addressbooklocation;
46
		}
47
		
48 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...
49
	    {
50
	    	$ablocations = Route4Me::makeRequst(array(
51
	            'url'    => self::$apiUrl,
52
	            'method' => 'GET',
53
	            'query'  => array(
54
	                'query' => $addressId,
55
	                'limit' => 30
56
	            )
57
	        ));
58
59
			return $ablocations;
60
		}
61
		
62 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...
63
	    {
64
	    	$result= Route4Me::makeRequst(array(
65
	            'url'    => self::$apiUrl,
66
	            'method' => 'GET',
67
	            'query'  => array(
68
	                'display' => isset($params['display']) ? $params['display']: null,
69
	                'query' => isset($params['query']) ? $params['query']: null,
70
	                'fields' => isset($params['fields']) ? $params['fields']: null,
71
	                'limit' => isset($params['limit']) ? $params['limit']: null,
72
	                'offset' => isset($params['offset']) ? $params['offset'] : null,
73
	            )
74
	        ));
75
76
			return $result;
77
		}
78
		
79 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...
80
	    {
81
	    	$ablocations = Route4Me::makeRequst(array(
82
	            'url'    => self::$apiUrl,
83
	            'method' => 'GET',
84
	            'query'  => array(
85
	                'limit' => isset($params->limit) ? $params->limit: null,
86
	                'offset' => isset($params->offset) ? $params->offset : null,
87
	            )
88
	        ));
89
90
			return $ablocations;
91
		}
92
		
93 View Code Duplication
		public static function getAddressBookLocationsByIds($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...
94
	    {
95
	    	$ablocations = Route4Me::makeRequst(array(
96
	            'url'    => self::$apiUrl,
97
	            'method' => 'GET',
98
	            'query'  => array(
99
	                'address_id' => $ids
100
	            )
101
	        ));
102
103
			return $ablocations;
104
		}
105
		
106
		public static function addAdressBookLocation($params)
107
	    {
108
	    	$ablocations = Route4Me::makeRequst(array(
109
	            'url'    => self::$apiUrl,
110
	            'method' => 'POST',
111
	            'body'  => array(
112
	            	'address_1' => 	isset($params->address_1) ? $params->address_1: null,
113
	            	'address_2' =>    isset($params->address_2) ? $params->address_2: null,
114
	            	'address_alias' =>    isset($params->address_alias) ? $params->address_alias: null,
115
	                'first_name' => isset($params->first_name) ? $params->first_name : null,
116
	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
117
	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
118
	                'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null,
119
                    'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null,
120
	                'address_phone_number' =>    isset($params->address_phone_number) ? $params->address_phone_number: null,
121
	                'address_group' =>    isset($params->address_group) ? $params->address_group: null,
122
	                'first_name' =>    isset($params->first_name) ? $params->first_name: null,
123
	                'last_name' =>    isset($params->last_name) ? $params->last_name: null,
124
                    'local_time_window_start' =>    isset($params->local_time_window_start) ? $params->local_time_window_start: null,
125
                    'local_time_window_end' =>    isset($params->local_time_window_end) ? $params->local_time_window_end: null,
126
                    'local_time_window_start_2' =>    isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
127
                    'local_time_window_end_2' =>    isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
128
	                'address_email' =>    isset($params->address_email) ? $params->address_email: null,
129
	                'address_city' =>    isset($params->address_city) ? $params->address_city: null,
130
	                'address_state_id' =>    isset($params->address_state_id) ? $params->address_state_id: null,
131
	                'address_country_id' =>    isset($params->address_country_id) ? $params->address_country_id: null,
132
	                'address_zip' =>    isset($params->address_zip) ? $params->address_zip: null,
133
	                'address_custom_data' =>    isset($params->address_custom_data) ? $params->address_custom_data: null,
134
	                'schedule' =>    isset($params->schedule) ? $params->schedule: null,
135
	                'schedule_blacklist' =>    isset($params->schedule_blacklist) ? $params->schedule_blacklist: null,
136
	                'service_time' =>    isset($params->service_time) ? $params->service_time: null,
137
	                'local_timezone_string' =>    isset($params->local_timezone_string) ? $params->local_timezone_string: null,
138
	                'color' =>    isset($params->color) ? $params->color: null,
139
	                'address_icon' =>    isset($params->address_icon) ? $params->address_icon: null,
140
	                'address_stop_type' =>    isset($params->address_stop_type) ? $params->address_stop_type: null,
141
	                'address_cube' =>    isset($params->address_cube) ? $params->address_cube: null,
142
	                'address_pieces' =>    isset($params->address_pieces) ? $params->address_pieces: null,
143
	                'address_reference_no' =>    isset($params->address_reference_no) ? $params->address_reference_no: null,
144
	                'address_revenue' =>    isset($params->address_revenue) ? $params->address_revenue: null,
145
	                'address_weight' =>    isset($params->address_weight) ? $params->address_weight: null,
146
	                'address_priority' =>    isset($params->address_priority) ? $params->address_priority: null,
147
	                'address_customer_po' =>    isset($params->address_customer_po) ? $params->address_customer_po: null,
148
	            )
149
	        ));
150
151
			return $ablocations;
152
		}
153
		
154 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...
155
	    {
156
	        $address = Route4Me::makeRequst(array(
157
	            'url'    => self::$apiUrl,
158
	            'method' => 'DELETEARRAY',
159
	            'query'  => array(
160
	                'address_ids'     => $address_ids
161
	            )
162
	        ));
163
	
164
	        return $address;
165
	    }
166
		
167
		public function updateAdressBookLocation($params)
168
	    {
169
	    	//echo "address_id --> ".$params["address_id"]."<br";
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
170
	        $address = Route4Me::makeRequst(array(
171
	            'url'    => self::$apiUrl,
172
	            'method' => 'PUT',
173
	            'query'   => $params,
174
175
	        ));
176
	
177
	        return $address;
178
	    }
179
			
180 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...
181
	    {
182
	    	$ablocations = Route4Me::makeRequst(array(
183
	            'url'    => self::$apiUrl,
184
	            'method' => 'ADD',
185
	            'query'  => array(
186
	                'first_name' => isset($params->first_name) ? $params->first_name : null,
187
	                'address_1' => isset($params->address_1) ? $params->address_1: null,
188
	                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
189
	                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
190
	            )
191
	        ));
192
193
			return $ablocations;
194
		}
195
        
196
        public static function validateScheduleMode($scheduleMode)
197
        {
198
            $schedMmodes=array("daily","weekly","monthly","annually");
199
            
200
            if (in_array($scheduleMode, $schedMmodes)) return TRUE; else return FALSE;
201
        }
202
        
203
        public static function validateScheduleEnable($scheduleEnabled)
204
        {
205
            $schedEnambles=array(TRUE,FALSE);
206
            
207
            if (in_array($scheduleEnabled, $schedEnambles)) return TRUE; else return FALSE;
208
        }
209
        
210
        public static function validateScheduleEvery($scheduleEvery)
211
        {
212
            if (is_numeric($scheduleEvery)) return TRUE; else return FALSE;
213
        }
214
        
215 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...
216
        {
217
            $weekdays = explode(',', $scheduleWeekDays);
218
            
219
            if (sizeof($weekdays)<1) return FALSE;
220
            
221
            $isValid=TRUE;
222
            
223
            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...
224
                if (is_numeric($weekdays[$i])) {
225
                    $wday=intval($weekdays[$i]);
226
                    if ($wday<1 || $wday>7) $isValid=FALSE;
227
                }
228
                else $isValid=FALSE;
229
            }
230
            //echo $scheduleWeekDays.' --- '. $isValid."<br>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
231
            return $isValid;
232
        }
233
        
234
        public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
235
        {
236
            $schedMonthlyMmodes=array("dates","nth");
237
            
238
            if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) return TRUE; else return FALSE;
239
        }
240
        
241 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...
242
        {
243
            $monthlyDates = explode(',', $scheduleMonthlyDates);
244
            
245
            if (sizeof($monthlyDates)<1) return FALSE;
246
            
247
            $isValid=TRUE;
248
            
249
            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...
250
                if (is_numeric($monthlyDates[$i])) {
251
                    $mday=intval($monthlyDates[$i]);
252
                    if ($mday<1 || $mday>31) $isValid=FALSE;
253
                }
254
                else $isValid=FALSE;
255
            }
256
            //echo $scheduleMonthlyDates.' --- '. $isValid."<br>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
257
            return $isValid;
258
        }
259
        
260
        public static function validateScheduleNthN($scheduleNthN)
261
        {
262
            if (!is_numeric($scheduleNthN)) return FALSE;
263
            
264
            $schedNthNs=array(1,2,3,4,5,-1);
265
            if (in_array($scheduleNthN, $schedNthNs)) return TRUE; else return FALSE;
266
        }
267
        
268
        public static function validateScheduleNthWhat($scheduleNthWhat)
269
        {
270
            if (!is_numeric($scheduleNthWhat)) return FALSE;
271
            
272
            $schedNthWhats=array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
273
            if (in_array($scheduleNthWhat, $schedNthWhats)) return TRUE; else return FALSE;
274
        }
275
	}
276
	
277
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
278