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 ( 07471e...521018 )
by Oleg
02:22
created
src/Route4Me/Vehicle.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -6,157 +6,157 @@
 block discarded – undo
6 6
 
7 7
 class Vehicle extends Common
8 8
 {
9
-    public $vehicle_id;
10
-    public $member_id;
11
-    public $is_deleted;
12
-    public $vehicle_alias;
13
-    public $vehicle_vin;
14
-    public $vehicle_reg_state_id;
15
-    public $vehicle_reg_country_id;
16
-    public $vehicle_license_plate;
17
-    public $vehicle_type_id;
18
-    public $vehicle_make;
19
-    public $vehicle_model_year;
20
-    public $vehicle_model;
21
-    public $vehicle_year_acquired;
22
-    public $vehicle_cost_new;
23
-    public $purchased_new;
24
-    public $license_start_date;
25
-    public $license_end_date;
26
-    public $vehicle_axle_count;
27
-    public $is_operational;
28
-    public $mpg_city;
29
-    public $mpg_highway;
30
-    public $fuel_type;
31
-    public $height_inches;
32
-    public $weight_lb;
33
-    public $external_telematics_vehicle_id;
34
-    public $has_trailer;
35
-    public $heightInInches;
36
-    public $lengthInInches;
37
-    public $widthInInches;
38
-    public $maxWeightPerAxleGroupInPounds;
39
-    public $numAxles;
40
-    public $weightInPounds;
41
-    public $HazmatType;
42
-    public $LowEmissionZonePref;
43
-    public $Use53FootTrailerRouting;
44
-    public $UseNationalNetwork;
45
-    public $UseTruckRestrictions;
46
-    public $AvoidFerries;
47
-    public $DividedHighwayAvoidPreference;
48
-    public $FreewayAvoidPreference;
49
-    public $InternationalBordersOpen;
50
-    public $TollRoadUsage;
51
-    public $hwy_only;
52
-    public $long_combination_vehicle;
53
-    public $avoid_highways;
54
-    public $side_street_adherence;
55
-    public $truck_config;
56
-    public $height_metric;
57
-    public $length_metric;
58
-    public $width_metric;
59
-    public $weight_metric;
60
-    public $max_weight_per_axle_group_metric;
9
+	public $vehicle_id;
10
+	public $member_id;
11
+	public $is_deleted;
12
+	public $vehicle_alias;
13
+	public $vehicle_vin;
14
+	public $vehicle_reg_state_id;
15
+	public $vehicle_reg_country_id;
16
+	public $vehicle_license_plate;
17
+	public $vehicle_type_id;
18
+	public $vehicle_make;
19
+	public $vehicle_model_year;
20
+	public $vehicle_model;
21
+	public $vehicle_year_acquired;
22
+	public $vehicle_cost_new;
23
+	public $purchased_new;
24
+	public $license_start_date;
25
+	public $license_end_date;
26
+	public $vehicle_axle_count;
27
+	public $is_operational;
28
+	public $mpg_city;
29
+	public $mpg_highway;
30
+	public $fuel_type;
31
+	public $height_inches;
32
+	public $weight_lb;
33
+	public $external_telematics_vehicle_id;
34
+	public $has_trailer;
35
+	public $heightInInches;
36
+	public $lengthInInches;
37
+	public $widthInInches;
38
+	public $maxWeightPerAxleGroupInPounds;
39
+	public $numAxles;
40
+	public $weightInPounds;
41
+	public $HazmatType;
42
+	public $LowEmissionZonePref;
43
+	public $Use53FootTrailerRouting;
44
+	public $UseNationalNetwork;
45
+	public $UseTruckRestrictions;
46
+	public $AvoidFerries;
47
+	public $DividedHighwayAvoidPreference;
48
+	public $FreewayAvoidPreference;
49
+	public $InternationalBordersOpen;
50
+	public $TollRoadUsage;
51
+	public $hwy_only;
52
+	public $long_combination_vehicle;
53
+	public $avoid_highways;
54
+	public $side_street_adherence;
55
+	public $truck_config;
56
+	public $height_metric;
57
+	public $length_metric;
58
+	public $width_metric;
59
+	public $weight_metric;
60
+	public $max_weight_per_axle_group_metric;
61 61
     
62
-    public function __construct () 
63
-    {
64
-        Route4Me::setBaseUrl(Endpoint::WH_BASE_URL);
65
-    }
62
+	public function __construct () 
63
+	{
64
+		Route4Me::setBaseUrl(Endpoint::WH_BASE_URL);
65
+	}
66 66
     
67
-    public static function fromArray(array $params) {
68
-        $vehicle= new Vehicle();
69
-        foreach ($params as $key => $value) {
70
-            if (property_exists($vehicle, $key)) {
71
-                $vehicle->{$key} = $value;
72
-            }
73
-        }
67
+	public static function fromArray(array $params) {
68
+		$vehicle= new Vehicle();
69
+		foreach ($params as $key => $value) {
70
+			if (property_exists($vehicle, $key)) {
71
+				$vehicle->{$key} = $value;
72
+			}
73
+		}
74 74
         
75
-        return $vehicle;
76
-    }
75
+		return $vehicle;
76
+	}
77 77
     
78
-    public static function getVehicles($params)
79
-    {
80
-        $allQueryFields = array('with_pagination', 'page', 'perPage');
78
+	public static function getVehicles($params)
79
+	{
80
+		$allQueryFields = array('with_pagination', 'page', 'perPage');
81 81
         
82
-        $response = Route4Me::makeRequst(array(
83
-            'url'    => Endpoint::VEHICLE_V4,
84
-            'method' => 'GET',
85
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
86
-        ));
82
+		$response = Route4Me::makeRequst(array(
83
+			'url'    => Endpoint::VEHICLE_V4,
84
+			'method' => 'GET',
85
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
86
+		));
87 87
 
88
-        return $response;
89
-    }
88
+		return $response;
89
+	}
90 90
     
91
-    public function getRandomVehicleId($page,$perPage)
92
-    {
93
-        $params = array(
94
-            'page'             => isset($page) ? $page : 1,
95
-            'perPage'          => isset($perPage) ? $perPage : 10,
96
-            'with_pagination'  => true
97
-        );
91
+	public function getRandomVehicleId($page,$perPage)
92
+	{
93
+		$params = array(
94
+			'page'             => isset($page) ? $page : 1,
95
+			'perPage'          => isset($perPage) ? $perPage : 10,
96
+			'with_pagination'  => true
97
+		);
98 98
         
99
-        $vehicles = $this->getVehicles($params);
99
+		$vehicles = $this->getVehicles($params);
100 100
 
101
-        if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data'])<1) {
102
-            return null;
103
-        }
101
+		if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data'])<1) {
102
+			return null;
103
+		}
104 104
         
105
-        $randomIndex = rand(0, sizeof($vehicles['data']) - 1);
105
+		$randomIndex = rand(0, sizeof($vehicles['data']) - 1);
106 106
         
107
-        return $vehicles['data'][$randomIndex]['vehicle_id'];
108
-    }
107
+		return $vehicles['data'][$randomIndex]['vehicle_id'];
108
+	}
109 109
     
110
-    public function getVehicleByID($vehicleID)
111
-    {
112
-        $response = Route4Me::makeRequst(array(
113
-            'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
114
-            'method' => 'GET'
115
-        ));
110
+	public function getVehicleByID($vehicleID)
111
+	{
112
+		$response = Route4Me::makeRequst(array(
113
+			'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
114
+			'method' => 'GET'
115
+		));
116 116
 
117
-        return $response;
118
-    }
117
+		return $response;
118
+	}
119 119
     
120
-    public function updateVehicle($params)
121
-    {
122
-        $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null;
120
+	public function updateVehicle($params)
121
+	{
122
+		$vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null;
123 123
         
124
-        $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id'));
124
+		$allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id'));
125 125
         
126
-        $response = Route4Me::makeRequst(array(
127
-            'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
128
-            'method' => 'PUT',
129
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
130
-            'HTTPHEADER'  => 'Content-Type: application/json'
131
-        ));
126
+		$response = Route4Me::makeRequst(array(
127
+			'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
128
+			'method' => 'PUT',
129
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
130
+			'HTTPHEADER'  => 'Content-Type: application/json'
131
+		));
132 132
 
133
-        return $response;
134
-    }
133
+		return $response;
134
+	}
135 135
     
136
-    public function createVehicle($params)
137
-    {
138
-        $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id'));
136
+	public function createVehicle($params)
137
+	{
138
+		$allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id'));
139 139
         
140
-        $response = Route4Me::makeRequst(array(
141
-            'url'    => Endpoint::VEHICLE_V4,
142
-            'method' => 'POST',
143
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
144
-            'HTTPHEADER'  => 'Content-Type: application/json'
145
-        ));
140
+		$response = Route4Me::makeRequst(array(
141
+			'url'    => Endpoint::VEHICLE_V4,
142
+			'method' => 'POST',
143
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
144
+			'HTTPHEADER'  => 'Content-Type: application/json'
145
+		));
146 146
 
147
-        return $response;
148
-    }
147
+		return $response;
148
+	}
149 149
     
150
-    public function removeVehicle($params)
151
-    {
152
-        $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null;
150
+	public function removeVehicle($params)
151
+	{
152
+		$vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null;
153 153
         
154
-        $response = Route4Me::makeRequst(array(
155
-            'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
156
-            'method' => 'DELETE',
157
-            'HTTPHEADER'  => 'Content-Type: application/json'
158
-        ));
154
+		$response = Route4Me::makeRequst(array(
155
+			'url'    => Endpoint::VEHICLE_V4.'/'.$vehicleID,
156
+			'method' => 'DELETE',
157
+			'HTTPHEADER'  => 'Content-Type: application/json'
158
+		));
159 159
 
160
-        return $response;
161
-    }
160
+		return $response;
161
+	}
162 162
 }
Please login to merge, or discard this patch.
src/Route4Me/RouteParameters.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -5,74 +5,74 @@
 block discarded – undo
5 5
 
6 6
 class RouteParameters extends Common
7 7
 {
8
-    public $is_upload;
9
-    public $rt;
10
-    public $route_name;
11
-    public $route_date;
12
-    public $route_time;
13
-    public $shared_publicly;
14
-    public $disable_optimization;
15
-    public $optimize;
16
-    public $lock_last;
17
-    public $vehicle_capacity;
18
-    public $vehicle_max_distance_mi;
19
-    public $distance_unit;
20
-    public $travel_mode;
21
-    public $avoid;
22
-    public $vehicle_id;
23
-    public $dev_lat;
24
-    public $dev_lng;
25
-    public $route_max_duration;
26
-    public $route_email;
27
-    public $route_type = "api";
28
-    public $store_route = true;
29
-    public $metric;
30
-    public $algorithm_type;
31
-    public $member_id;
32
-    public $ip;
33
-    public $dm;
34
-    public $dirm;
35
-    public $parts;
36
-    public $device_id;
37
-    public $device_type;
38
-    public $has_trailer;
39
-    public $trailer_weight_t;
40
-    public $limited_weight_t;
41
-    public $weight_per_axle_t;
42
-    public $truck_height_meters;
43
-    public $truck_width_meters;
44
-    public $truck_length_meters;
45
-    public $truck_hazardous_goods;
8
+	public $is_upload;
9
+	public $rt;
10
+	public $route_name;
11
+	public $route_date;
12
+	public $route_time;
13
+	public $shared_publicly;
14
+	public $disable_optimization;
15
+	public $optimize;
16
+	public $lock_last;
17
+	public $vehicle_capacity;
18
+	public $vehicle_max_distance_mi;
19
+	public $distance_unit;
20
+	public $travel_mode;
21
+	public $avoid;
22
+	public $vehicle_id;
23
+	public $dev_lat;
24
+	public $dev_lng;
25
+	public $route_max_duration;
26
+	public $route_email;
27
+	public $route_type = "api";
28
+	public $store_route = true;
29
+	public $metric;
30
+	public $algorithm_type;
31
+	public $member_id;
32
+	public $ip;
33
+	public $dm;
34
+	public $dirm;
35
+	public $parts;
36
+	public $device_id;
37
+	public $device_type;
38
+	public $has_trailer;
39
+	public $trailer_weight_t;
40
+	public $limited_weight_t;
41
+	public $weight_per_axle_t;
42
+	public $truck_height_meters;
43
+	public $truck_width_meters;
44
+	public $truck_length_meters;
45
+	public $truck_hazardous_goods;
46 46
     
47
-    public $vehicle_max_cargo_weight;
48
-    public $vehicle_max_cargo_volume;
49
-    public $subtour_max_revenue;
50
-    public $avoidance_zones;
51
-    public $driver_id;
52
-    public $parts_min;
53
-    public $first_drive_then_wait_between_stops;
54
-    public $truck_height;
55
-    public $truck_width;
56
-    public $truck_length;
57
-    public $optimization_quality;
58
-    public $override_addresses;
59
-    public $max_tour_size;
60
-    public $min_tour_size;
61
-    public $uturn;
62
-    public $leftturn;
63
-    public $rightturn;
47
+	public $vehicle_max_cargo_weight;
48
+	public $vehicle_max_cargo_volume;
49
+	public $subtour_max_revenue;
50
+	public $avoidance_zones;
51
+	public $driver_id;
52
+	public $parts_min;
53
+	public $first_drive_then_wait_between_stops;
54
+	public $truck_height;
55
+	public $truck_width;
56
+	public $truck_length;
57
+	public $optimization_quality;
58
+	public $override_addresses;
59
+	public $max_tour_size;
60
+	public $min_tour_size;
61
+	public $uturn;
62
+	public $leftturn;
63
+	public $rightturn;
64 64
     
65
-    public $optimized_callback_url;
65
+	public $optimized_callback_url;
66 66
 
67
-    public static function fromArray(array $params)
68
-    {
69
-        $routeParams = new RouteParameters();
70
-        foreach ($params as $key => $value) {
71
-            if (property_exists($routeParams, $key)) {
72
-                $routeParams->{$key} = $value;
73
-            }
74
-        }
67
+	public static function fromArray(array $params)
68
+	{
69
+		$routeParams = new RouteParameters();
70
+		foreach ($params as $key => $value) {
71
+			if (property_exists($routeParams, $key)) {
72
+				$routeParams->{$key} = $value;
73
+			}
74
+		}
75 75
 
76
-        return $routeParams;
77
-    }
76
+		return $routeParams;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblemParams.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -7,93 +7,93 @@
 block discarded – undo
7 7
 
8 8
 class OptimizationProblemParams extends Common
9 9
 {
10
-    public $optimization_problem_id;
11
-    public $reoptimize;
12
-    public $addresses = array();
13
-    public $parameters;
14
-    public $directions;
15
-    public $format;
16
-    public $route_path_output;
17
-    public $optimized_callback_url;
18
-    public $redirect = true;
10
+	public $optimization_problem_id;
11
+	public $reoptimize;
12
+	public $addresses = array();
13
+	public $parameters;
14
+	public $directions;
15
+	public $format;
16
+	public $route_path_output;
17
+	public $optimized_callback_url;
18
+	public $redirect = true;
19 19
 
20
-    public static function fromArray($params)
21
-    {
22
-        $param = new OptimizationProblemParams;
23
-        if (!isset($params['addresses'])) {
24
-            throw new BadParam('addresses must be provided.');
25
-        }
20
+	public static function fromArray($params)
21
+	{
22
+		$param = new OptimizationProblemParams;
23
+		if (!isset($params['addresses'])) {
24
+			throw new BadParam('addresses must be provided.');
25
+		}
26 26
 
27
-        if (!isset($params['parameters'])) {
28
-            throw new BadParam('parameters must be provided.');
29
-        }
27
+		if (!isset($params['parameters'])) {
28
+			throw new BadParam('parameters must be provided.');
29
+		}
30 30
 
31
-        if ($params['parameters'] instanceof RouteParameters) {
32
-            $param->setParameters($params['parameters']);
33
-        } else {
34
-            $param->setParameters(RouteParameters::fromArray($params['parameters']));
35
-        }
31
+		if ($params['parameters'] instanceof RouteParameters) {
32
+			$param->setParameters($params['parameters']);
33
+		} else {
34
+			$param->setParameters(RouteParameters::fromArray($params['parameters']));
35
+		}
36 36
 
37
-        foreach($params['addresses'] as $address) {
38
-            if (!($address instanceof Address)) {
39
-                $address = Address::fromArray($address);
40
-            }
37
+		foreach($params['addresses'] as $address) {
38
+			if (!($address instanceof Address)) {
39
+				$address = Address::fromArray($address);
40
+			}
41 41
             
42
-            $param->addAddress($address);
43
-        }
42
+			$param->addAddress($address);
43
+		}
44 44
 
45
-        $param->directions = self::getValue($params, 'directions');
46
-        $param->format = self::getValue($params, 'format');
47
-        $param->route_path_output = self::getValue($params, 'route_path_output');
48
-        $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
49
-        $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
50
-        $param->reoptimize = self::getValue($params, 'reoptimize');
51
-        $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
45
+		$param->directions = self::getValue($params, 'directions');
46
+		$param->format = self::getValue($params, 'format');
47
+		$param->route_path_output = self::getValue($params, 'route_path_output');
48
+		$param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
49
+		$param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
50
+		$param->reoptimize = self::getValue($params, 'reoptimize');
51
+		$param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
52 52
 
53
-        return $param;
54
-    }
53
+		return $param;
54
+	}
55 55
 
56
-    public function __construct()
57
-    {
58
-        $this->parameters = new RouteParameters;
59
-    }
56
+	public function __construct()
57
+	{
58
+		$this->parameters = new RouteParameters;
59
+	}
60 60
 
61
-    public function setParameters(RouteParameters $params)
62
-    {
63
-        $this->parameters = $params;
61
+	public function setParameters(RouteParameters $params)
62
+	{
63
+		$this->parameters = $params;
64 64
         
65
-        return $this;
66
-    }
65
+		return $this;
66
+	}
67 67
 
68
-    public function addAddress(Address $address)
69
-    {
70
-        $this->addresses[] = $address;
68
+	public function addAddress(Address $address)
69
+	{
70
+		$this->addresses[] = $address;
71 71
         
72
-        return $this;
73
-    }
72
+		return $this;
73
+	}
74 74
     
75
-    public function getAddressesArray()
76
-    {
77
-        $addresses = array();
75
+	public function getAddressesArray()
76
+	{
77
+		$addresses = array();
78 78
         
79
-        foreach($this->addresses as $address) {
80
-            $addresses[] = $address->toArray();
81
-        }
79
+		foreach($this->addresses as $address) {
80
+			$addresses[] = $address->toArray();
81
+		}
82 82
         
83
-        return $addresses;
84
-    }
83
+		return $addresses;
84
+	}
85 85
 
86
-    public function getParametersArray()
87
-    {
88
-        return $this->parameters->toArray();
89
-    }
86
+	public function getParametersArray()
87
+	{
88
+		return $this->parameters->toArray();
89
+	}
90 90
 
91
-    public function setAddresses(array $addresses)
92
-    {
93
-        foreach ($addresses as $address) {
94
-            $this->addAddress($address);
95
-        }
91
+	public function setAddresses(array $addresses)
92
+	{
93
+		foreach ($addresses as $address) {
94
+			$this->addAddress($address);
95
+		}
96 96
         
97
-        return $this;
98
-    }
97
+		return $this;
98
+	}
99 99
 }
Please login to merge, or discard this patch.
src/Route4Me/Common.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@
 block discarded – undo
4 4
 
5 5
 class Common
6 6
 {
7
-    public static function getValue($array, $item, $default = null)
8
-    {
9
-        return (isset($array[$item])) ? $array[$item] : $default;
10
-    }
7
+	public static function getValue($array, $item, $default = null)
8
+	{
9
+		return (isset($array[$item])) ? $array[$item] : $default;
10
+	}
11 11
 
12
-    public function toArray()
13
-    {
14
-        $params = array_filter(get_object_vars($this), function($item) {
15
-            return ($item!==null) && !(is_array($item) && !count($item));
16
-        });
12
+	public function toArray()
13
+	{
14
+		$params = array_filter(get_object_vars($this), function($item) {
15
+			return ($item!==null) && !(is_array($item) && !count($item));
16
+		});
17 17
 
18
-        return $params;
19
-    }
18
+		return $params;
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Route4Me/AvoidanceZone.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -7,111 +7,111 @@
 block discarded – undo
7 7
 
8 8
 class AvoidanceZone extends Common
9 9
 {
10
-    public $territory_id;  // Avoidance zone id
11
-    public $territory_name; 
12
-    public $territory_color;
13
-    public $orders;
14
-    public $member_id;
15
-    public $territory; // Territory parameters
10
+	public $territory_id;  // Avoidance zone id
11
+	public $territory_name; 
12
+	public $territory_color;
13
+	public $orders;
14
+	public $member_id;
15
+	public $territory; // Territory parameters
16 16
     
17
-    public static function fromArray(array $params) 
18
-    {
19
-        if (!isset($params['territory_name'])) {
20
-            throw new BadParam('Territory name must be provided');
21
-        }
17
+	public static function fromArray(array $params) 
18
+	{
19
+		if (!isset($params['territory_name'])) {
20
+			throw new BadParam('Territory name must be provided');
21
+		}
22 22
         
23
-        if (!isset($params['territory_color'])) {
24
-            throw new BadParam('Territory color must be provided');
25
-        }
23
+		if (!isset($params['territory_color'])) {
24
+			throw new BadParam('Territory color must be provided');
25
+		}
26 26
         
27
-        if (!isset($params['territory'])) {
28
-            throw new BadParam('Territory must be provided');
29
-        }
27
+		if (!isset($params['territory'])) {
28
+			throw new BadParam('Territory must be provided');
29
+		}
30 30
         
31
-        $avoidanceZoneParameters = new AvoidanceZone();
31
+		$avoidanceZoneParameters = new AvoidanceZone();
32 32
         
33
-        foreach($params as $key => $value) {
34
-            if (property_exists($avoidanceZoneParameters, $key)) {
35
-                $avoidanceZoneParameters->{$key} = $value;
36
-            }
37
-        }
33
+		foreach($params as $key => $value) {
34
+			if (property_exists($avoidanceZoneParameters, $key)) {
35
+				$avoidanceZoneParameters->{$key} = $value;
36
+			}
37
+		}
38 38
         
39
-        return $avoidanceZoneParameters;
40
-    }
39
+		return $avoidanceZoneParameters;
40
+	}
41 41
     
42
-    public static function getAvoidanceZone($territory_id)
43
-    {
44
-        $avoidanceZone = Route4Me::makeRequst(array(
45
-            'url'    => Endpoint::AVOIDANCE_ZONE,
46
-            'method' => 'GET',
47
-            'query'  => array(
48
-                'territory_id' => $territory_id
49
-            )
50
-        ));
42
+	public static function getAvoidanceZone($territory_id)
43
+	{
44
+		$avoidanceZone = Route4Me::makeRequst(array(
45
+			'url'    => Endpoint::AVOIDANCE_ZONE,
46
+			'method' => 'GET',
47
+			'query'  => array(
48
+				'territory_id' => $territory_id
49
+			)
50
+		));
51 51
 
52
-        return $avoidanceZone;
53
-    }
52
+		return $avoidanceZone;
53
+	}
54 54
     
55
-    public static function getAvoidanceZones($params)
56
-    {
57
-        $avoidanceZones = Route4Me::makeRequst(array(
58
-            'url'    => Endpoint::AVOIDANCE_ZONE,
59
-            'method' => 'GET',
60
-            'query'  => array(
61
-                'offset'  => isset($params->offset) ? $params->offset : null,
62
-                'limit'   => isset($params->limit) ? $params->limit : null,
63
-            )
64
-        ));
55
+	public static function getAvoidanceZones($params)
56
+	{
57
+		$avoidanceZones = Route4Me::makeRequst(array(
58
+			'url'    => Endpoint::AVOIDANCE_ZONE,
59
+			'method' => 'GET',
60
+			'query'  => array(
61
+				'offset'  => isset($params->offset) ? $params->offset : null,
62
+				'limit'   => isset($params->limit) ? $params->limit : null,
63
+			)
64
+		));
65 65
 
66
-        return $avoidanceZones;
67
-    }
66
+		return $avoidanceZones;
67
+	}
68 68
 
69
-    public static function addAvoidanceZone($params)
70
-    {
71
-        $terParams = array();
69
+	public static function addAvoidanceZone($params)
70
+	{
71
+		$terParams = array();
72 72
 
73
-        if (isset($params->territory['type'])) {
74
-            $terParams['type'] = $params->territory['type'];
75
-        }
73
+		if (isset($params->territory['type'])) {
74
+			$terParams['type'] = $params->territory['type'];
75
+		}
76 76
         
77
-        if (isset($params->territory['data'])) {
78
-            $terParams['data'] = $params->territory['data'];
79
-        }
77
+		if (isset($params->territory['data'])) {
78
+			$terParams['data'] = $params->territory['data'];
79
+		}
80 80
 
81
-        $abContacts = Route4Me::makeRequst(array(
82
-            'url'    => Endpoint::AVOIDANCE_ZONE,
83
-            'method' => 'POST',
84
-            'body'  => array(
85
-                'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
86
-                'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
87
-                'territory'       => $terParams
88
-            )
89
-        ));
81
+		$abContacts = Route4Me::makeRequst(array(
82
+			'url'    => Endpoint::AVOIDANCE_ZONE,
83
+			'method' => 'POST',
84
+			'body'  => array(
85
+				'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
86
+				'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
87
+				'territory'       => $terParams
88
+			)
89
+		));
90 90
 
91
-        return $abContacts;
92
-    }
91
+		return $abContacts;
92
+	}
93 93
     
94
-    public function deleteAvoidanceZone($territory_id)
95
-    {
96
-        $result = Route4Me::makeRequst(array(
97
-            'url'    => Endpoint::AVOIDANCE_ZONE,
98
-            'method' => 'DELETEARRAY',
99
-            'query'  => array(
100
-                'territory_id' => $territory_id
101
-            )
102
-        ));
94
+	public function deleteAvoidanceZone($territory_id)
95
+	{
96
+		$result = Route4Me::makeRequst(array(
97
+			'url'    => Endpoint::AVOIDANCE_ZONE,
98
+			'method' => 'DELETEARRAY',
99
+			'query'  => array(
100
+				'territory_id' => $territory_id
101
+			)
102
+		));
103 103
 
104
-        return $result;
105
-    }
104
+		return $result;
105
+	}
106 106
     
107
-    public function updateAvoidanceZone($params)
108
-    {
109
-        $avoidanceZone = Route4Me::makeRequst(array(
110
-            'url'    => Endpoint::AVOIDANCE_ZONE,
111
-            'method' => 'PUT',
112
-            'body'   => $params,
113
-        ));
107
+	public function updateAvoidanceZone($params)
108
+	{
109
+		$avoidanceZone = Route4Me::makeRequst(array(
110
+			'url'    => Endpoint::AVOIDANCE_ZONE,
111
+			'method' => 'PUT',
112
+			'body'   => $params,
113
+		));
114 114
 
115
-        return $avoidanceZone;
116
-    }
115
+		return $avoidanceZone;
116
+	}
117 117
 }
Please login to merge, or discard this patch.
examples/MultipleDepotMultipleDriverWith24StopsTimeWindow.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 
27 27
 $addresses = array();
28 28
 foreach ($json as $address) {
29
-    $addresses[] = Address::fromArray($address);
29
+	$addresses[] = Address::fromArray($address);
30 30
 }
31 31
 
32 32
 $parameters = RouteParameters::fromArray(array(
33
-    "algorithm_type"          => Algorithmtype::CVRP_TW_SD,
34
-    "route_name"              => "Multiple Depot, Multiple Driver with 24 Stops, Time Window",
35
-    "route_date"              => time() + 24*60*60,
36
-    "route_time"              => 60 * 60 * 7,
37
-    "distance_unit"           => DistanceUnit::MILES,
38
-    "device_type"             => DeviceType::WEB,
39
-    "optimize"                => OptimizationType::DISTANCE,
40
-    "metric"                  => Metric::GEODESIC,
41
-    "route_max_duration"      => 86400,
42
-    "travel_mode"             => TravelMode::DRIVING,
43
-    "vehicle_capacity"        => 1,
44
-    "vehicle_max_distance_mi" => 10000
33
+	"algorithm_type"          => Algorithmtype::CVRP_TW_SD,
34
+	"route_name"              => "Multiple Depot, Multiple Driver with 24 Stops, Time Window",
35
+	"route_date"              => time() + 24*60*60,
36
+	"route_time"              => 60 * 60 * 7,
37
+	"distance_unit"           => DistanceUnit::MILES,
38
+	"device_type"             => DeviceType::WEB,
39
+	"optimize"                => OptimizationType::DISTANCE,
40
+	"metric"                  => Metric::GEODESIC,
41
+	"route_max_duration"      => 86400,
42
+	"travel_mode"             => TravelMode::DRIVING,
43
+	"vehicle_capacity"        => 1,
44
+	"vehicle_max_distance_mi" => 10000
45 45
 ));
46 46
 
47 47
 $optimizationParams = new OptimizationProblemParams;
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 $problem = OptimizationProblem::optimize($optimizationParams);
52 52
 
53 53
 foreach ((array)$problem as $key => $value) {
54
-    if (is_string($value)) {
55
-        echo $key." --> ".$value."<br>";
56
-    } else {
57
-        echo "************ $key ************* <br>";
58
-        Route4Me::simplePrint((array)$value, true);
59
-        echo "******************************* <br>";
60
-    }
54
+	if (is_string($value)) {
55
+		echo $key." --> ".$value."<br>";
56
+	} else {
57
+		echo "************ $key ************* <br>";
58
+		Route4Me::simplePrint((array)$value, true);
59
+		echo "******************************* <br>";
60
+	}
61 61
 }
Please login to merge, or discard this patch.
examples/single_driver_route_ten_stops.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@
 block discarded – undo
26 26
 
27 27
 $addresses = array();
28 28
 foreach ($json as $address) {
29
-    $addresses[] = Address::fromArray($address);
29
+	$addresses[] = Address::fromArray($address);
30 30
 }
31 31
 
32 32
 $parameters = RouteParameters::fromArray(array(
33
-    "algorithm_type"          => AlgorithmType::TSP,
34
-    "distance_unit"           => DistanceUnit::MILES,
35
-    "device_type"             => DeviceType::WEB,
36
-    "optimize"                => OptimizationType::DISTANCE,
37
-    "travel_mode"             => TravelMode::DRIVING,
38
-    "route_max_duration"      => 86400,
39
-    "vehicle_capacity"        => 1,
40
-    "vehicle_max_distance_mi" => 10000
33
+	"algorithm_type"          => AlgorithmType::TSP,
34
+	"distance_unit"           => DistanceUnit::MILES,
35
+	"device_type"             => DeviceType::WEB,
36
+	"optimize"                => OptimizationType::DISTANCE,
37
+	"travel_mode"             => TravelMode::DRIVING,
38
+	"route_max_duration"      => 86400,
39
+	"vehicle_capacity"        => 1,
40
+	"vehicle_max_distance_mi" => 10000
41 41
 ));
42 42
 
43 43
 $optimizationParams = new OptimizationProblemParams;
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 1 patch
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -7,342 +7,342 @@
 block discarded – undo
7 7
 
8 8
 class Route4Me
9 9
 {
10
-    static public $apiKey;
11
-    static public $baseUrl = Endpoint::BASE_URL;
10
+	static public $apiKey;
11
+	static public $baseUrl = Endpoint::BASE_URL;
12 12
 
13
-    public static function setApiKey($apiKey)
14
-    {
15
-        self::$apiKey = $apiKey;
16
-    }
13
+	public static function setApiKey($apiKey)
14
+	{
15
+		self::$apiKey = $apiKey;
16
+	}
17 17
 
18
-    public static function getApiKey()
19
-    {
20
-        return self::$apiKey;
21
-    }
18
+	public static function getApiKey()
19
+	{
20
+		return self::$apiKey;
21
+	}
22 22
 
23
-    public static function setBaseUrl($baseUrl)
24
-    {
25
-        self::$baseUrl = $baseUrl;
26
-    }
23
+	public static function setBaseUrl($baseUrl)
24
+	{
25
+		self::$baseUrl = $baseUrl;
26
+	}
27 27
 
28
-    public static function getBaseUrl()
29
-    {
30
-        return self::$baseUrl;
31
-    }
28
+	public static function getBaseUrl()
29
+	{
30
+		return self::$baseUrl;
31
+	}
32 32
     
33
-    public static function fileUploadRequest($options) {
34
-        $query = isset($options['query']) ? array_filter($options['query']) : array();
33
+	public static function fileUploadRequest($options) {
34
+		$query = isset($options['query']) ? array_filter($options['query']) : array();
35 35
 
36
-        if (sizeof($query)==0) {
37
-            return null;
38
-        }
36
+		if (sizeof($query)==0) {
37
+			return null;
38
+		}
39 39
         
40
-        $body = isset($options['body']) ? array_filter($options['body']) : null;
40
+		$body = isset($options['body']) ? array_filter($options['body']) : null;
41 41
             
42
-        $fname = isset($body['strFilename']) ? $body['strFilename'] : '';
42
+		$fname = isset($body['strFilename']) ? $body['strFilename'] : '';
43 43
         
44
-        if ($fname=='') {
45
-            return null;  
46
-        } 
44
+		if ($fname=='') {
45
+			return null;  
46
+		} 
47 47
 
48
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
48
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
49 49
         
50
-        $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query));
50
+		$url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query));
51 51
         
52
-        $ch = curl_init($url);
52
+		$ch = curl_init($url);
53 53
         
54
-        $curlOpts = array(
55
-            CURLOPT_POST => true,
56
-            CURLOPT_RETURNTRANSFER => false,
57
-            CURLOPT_TIMEOUT        => 60,
58
-            CURLOPT_FOLLOWLOCATION => true,
59
-            CURLOPT_SSL_VERIFYHOST => FALSE,
60
-            CURLOPT_SSL_VERIFYPEER => FALSE
61
-        );
54
+		$curlOpts = array(
55
+			CURLOPT_POST => true,
56
+			CURLOPT_RETURNTRANSFER => false,
57
+			CURLOPT_TIMEOUT        => 60,
58
+			CURLOPT_FOLLOWLOCATION => true,
59
+			CURLOPT_SSL_VERIFYHOST => FALSE,
60
+			CURLOPT_SSL_VERIFYPEER => FALSE
61
+		);
62 62
         
63
-        curl_setopt_array($ch, $curlOpts);
63
+		curl_setopt_array($ch, $curlOpts);
64 64
         
65
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
65
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
66 66
         
67
-        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
68
-            "Content-Type: multipart/form-data",
69
-            'Content-Disposition: form-data; name="strFilename"'
70
-        ));
67
+		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
68
+			"Content-Type: multipart/form-data",
69
+			'Content-Disposition: form-data; name="strFilename"'
70
+		));
71 71
         
72
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
73
-        curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); 
72
+		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
73
+		curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); 
74 74
         
75
-        $result = curl_exec($ch);
75
+		$result = curl_exec($ch);
76 76
 
77
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
78
-        curl_close($ch);
77
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
78
+		curl_close($ch);
79 79
 
80
-        $json = json_decode($result, true);
80
+		$json = json_decode($result, true);
81 81
         
82
-        if (200==$code) {
83
-            return $json;
84
-        } elseif (isset($json['errors'])) {
85
-            throw new ApiError(implode(', ', $json['errors']));
86
-        } else {
87
-            throw new ApiError('Something wrong');
88
-        }
89
-    }
82
+		if (200==$code) {
83
+			return $json;
84
+		} elseif (isset($json['errors'])) {
85
+			throw new ApiError(implode(', ', $json['errors']));
86
+		} else {
87
+			throw new ApiError('Something wrong');
88
+		}
89
+	}
90 90
 
91
-    public static function makeRequst($options) {
92
-        $errorHandler = new myErrorHandler();
91
+	public static function makeRequst($options) {
92
+		$errorHandler = new myErrorHandler();
93 93
 
94
-        $old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
94
+		$old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
95 95
 
96
-        $method = isset($options['method']) ? $options['method'] : 'GET';
97
-        $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
96
+		$method = isset($options['method']) ? $options['method'] : 'GET';
97
+		$query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
98 98
 
99
-        $body = isset($options['body']) ? $options['body'] : null;
100
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
101
-        $headers = array(
102
-            "User-Agent: Route4Me php-sdk"
103
-        );
99
+		$body = isset($options['body']) ? $options['body'] : null;
100
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
101
+		$headers = array(
102
+			"User-Agent: Route4Me php-sdk"
103
+		);
104 104
 
105
-        if (isset($options['HTTPHEADER'])) {
106
-            $headers[] = $options['HTTPHEADER'];
107
-        }
105
+		if (isset($options['HTTPHEADER'])) {
106
+			$headers[] = $options['HTTPHEADER'];
107
+		}
108 108
 
109
-        if (isset($options['HTTPHEADERS'])) {
110
-            foreach ($options['HTTPHEADERS'] As $header) {
111
-                $headers[] = $header;
112
-            } 
113
-        }
109
+		if (isset($options['HTTPHEADERS'])) {
110
+			foreach ($options['HTTPHEADERS'] As $header) {
111
+				$headers[] = $header;
112
+			} 
113
+		}
114 114
 
115
-        $ch = curl_init();
115
+		$ch = curl_init();
116 116
 
117
-        $url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
118
-            $query, array('api_key' => self::getApiKey())
119
-        )) : "";
117
+		$url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
118
+			$query, array('api_key' => self::getApiKey())
119
+		)) : "";
120 120
 
121
-        $baseUrl = self::getBaseUrl();
121
+		$baseUrl = self::getBaseUrl();
122 122
  
123
-        $curlOpts = array(
124
-            CURLOPT_URL            => $baseUrl.$url,
125
-            CURLOPT_RETURNTRANSFER => true,
126
-            CURLOPT_TIMEOUT        => 80,
127
-            CURLOPT_FOLLOWLOCATION => true,
128
-            CURLOPT_SSL_VERIFYHOST => FALSE,
129
-            CURLOPT_SSL_VERIFYPEER => FALSE,
130
-            CURLOPT_HTTPHEADER     => $headers
131
-        );
123
+		$curlOpts = array(
124
+			CURLOPT_URL            => $baseUrl.$url,
125
+			CURLOPT_RETURNTRANSFER => true,
126
+			CURLOPT_TIMEOUT        => 80,
127
+			CURLOPT_FOLLOWLOCATION => true,
128
+			CURLOPT_SSL_VERIFYHOST => FALSE,
129
+			CURLOPT_SSL_VERIFYPEER => FALSE,
130
+			CURLOPT_HTTPHEADER     => $headers
131
+		);
132 132
         
133
-        curl_setopt_array($ch, $curlOpts);
133
+		curl_setopt_array($ch, $curlOpts);
134 134
         
135
-        if ($file!=null) {
136
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
137
-            $fp=fopen($file, 'r');
138
-            curl_setopt($ch, CURLOPT_INFILE, $fp);
139
-            curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
140
-        }
135
+		if ($file!=null) {
136
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
137
+			$fp=fopen($file, 'r');
138
+			curl_setopt($ch, CURLOPT_INFILE, $fp);
139
+			curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
140
+		}
141 141
 
142
-        switch ($method) {
143
-        case 'DELETE':
144
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
145
-            break;
146
-        case 'DELETEARRAY':
147
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
148
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
149
-            break;
150
-        case 'PUT':
151
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
152
-            break;
153
-        case 'POST':
154
-           if (isset($body)) {
155
-                $bodyData = json_encode($body);
156
-               if (isset($options['HTTPHEADER'])) {
157
-                  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) {
158
-                      $bodyData = $body;
159
-                  }
160
-               }
142
+		switch ($method) {
143
+		case 'DELETE':
144
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
145
+			break;
146
+		case 'DELETEARRAY':
147
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
148
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
149
+			break;
150
+		case 'PUT':
151
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
152
+			break;
153
+		case 'POST':
154
+		   if (isset($body)) {
155
+				$bodyData = json_encode($body);
156
+			   if (isset($options['HTTPHEADER'])) {
157
+				  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) {
158
+					  $bodyData = $body;
159
+				  }
160
+			   }
161 161
                
162
-               curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
163
-            } 
164
-            break;
165
-        case 'ADD':
166
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
167
-        }
162
+			   curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
163
+			} 
164
+			break;
165
+		case 'ADD':
166
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
167
+		}
168 168
 
169
-        if (is_numeric(array_search($method, array('DELETE', 'PUT')))) {
170
-            if (isset($body)) {
171
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
172
-            } 
173
-        }
169
+		if (is_numeric(array_search($method, array('DELETE', 'PUT')))) {
170
+			if (isset($body)) {
171
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
172
+			} 
173
+		}
174 174
 
175
-        $result = curl_exec($ch);
175
+		$result = curl_exec($ch);
176 176
 
177
-        $isxml = FALSE;
178
-        $jxml = "";
179
-        if (strpos($result, '<?xml')>-1) {
180
-            $xml = simplexml_load_string($result);
181
-            //$jxml = json_encode($xml);
182
-            $jxml = self::object2array($xml);
183
-            $isxml = TRUE;
184
-        }
177
+		$isxml = FALSE;
178
+		$jxml = "";
179
+		if (strpos($result, '<?xml')>-1) {
180
+			$xml = simplexml_load_string($result);
181
+			//$jxml = json_encode($xml);
182
+			$jxml = self::object2array($xml);
183
+			$isxml = TRUE;
184
+		}
185 185
         
186
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
187
-        curl_close($ch);
186
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
187
+		curl_close($ch);
188 188
         
189
-        if (200==$code) {
190
-            if ($isxml) {
191
-                $json = $jxml;
192
-            } else {
193
-                $json = json_decode($result, true);
194
-            }
189
+		if (200==$code) {
190
+			if ($isxml) {
191
+				$json = $jxml;
192
+			} else {
193
+				$json = json_decode($result, true);
194
+			}
195 195
             
196
-            if (isset($json['errors'])) {
197
-                throw new ApiError(implode(', ', $json['errors']));
198
-            } else {
199
-                return $json;
200
-            }
201
-        } elseif (409==$code) {
202
-            throw new ApiError('Wrong API key');
203
-        } else {
204
-            throw new ApiError('Something wrong');
205
-        }
206
-    }
196
+			if (isset($json['errors'])) {
197
+				throw new ApiError(implode(', ', $json['errors']));
198
+			} else {
199
+				return $json;
200
+			}
201
+		} elseif (409==$code) {
202
+			throw new ApiError('Wrong API key');
203
+		} else {
204
+			throw new ApiError('Something wrong');
205
+		}
206
+	}
207 207
 
208
-    /**
209
-     * @param $object: JSON object
210
-     */
211
-    public static function object2array($object)
212
-    {
213
-        return @json_decode(@json_encode($object), 1);
214
-    }
208
+	/**
209
+	 * @param $object: JSON object
210
+	 */
211
+	public static function object2array($object)
212
+	{
213
+		return @json_decode(@json_encode($object), 1);
214
+	}
215 215
 
216 216
     
217
-    /**
218
-     * Prints on the screen main keys and values of the array 
219
-     * @param $results: object to be printed on the screen.
220
-     * @param $deepPrinting: if true, object will be printed recursively.
221
-     */
222
-    public static function simplePrint($results, $deepPrinting = null)
223
-    {
224
-        if (isset($results)) {
225
-            if (is_array($results)) {
226
-                foreach ($results as $key=>$result) {
227
-                    if (is_array($result)) {
228
-                        foreach ($result as $key1=>$result1) {
229
-                            if (is_array($result1)) {
230
-                                  if ($deepPrinting) {
231
-                                      echo "<br>$key1 ------><br>";
232
-                                      Route4Me::simplePrint($result1, true);
233
-                                      echo "------<br>";
234
-                                  } else {
235
-                                      echo $key1." --> "."Array() <br>";
236
-                                  } 
237
-                            } else {
238
-                                if (is_object($result1)) {
239
-                                    if ($deepPrinting) {
240
-                                        echo "<br>$key1 ------><br>";
241
-                                        $oarray = (array)$result1;
242
-                                        Route4Me::simplePrint($oarray, true);
243
-                                        echo "------<br>";
244
-                                    } else {
245
-                                        echo $key1." --> "."Object <br>";
246
-                                    } 
247
-                                } else {
248
-                                    if (!is_null($result1)) {
249
-                                        echo $key1." --> ".$result1."<br>"; 
250
-                                    }   
251
-                                }
252
-                            }
253
-                        }
254
-                    } else {
255
-                        if (is_object($result)) {
256
-                            if ($deepPrinting) {
257
-                                echo "<br>$key ------><br>";
258
-                                $oarray = (array)$result;
259
-                                Route4Me::simplePrint($oarray, true);
260
-                                echo "------<br>";
261
-                            } else {
262
-                                echo $key." --> "."Object <br>";
263
-                            } 
264
-                        } else {
265
-                            if (!is_null($result)) {
266
-                                echo $key." --> ".$result."<br>";
267
-                            }
268
-                        }
217
+	/**
218
+	 * Prints on the screen main keys and values of the array 
219
+	 * @param $results: object to be printed on the screen.
220
+	 * @param $deepPrinting: if true, object will be printed recursively.
221
+	 */
222
+	public static function simplePrint($results, $deepPrinting = null)
223
+	{
224
+		if (isset($results)) {
225
+			if (is_array($results)) {
226
+				foreach ($results as $key=>$result) {
227
+					if (is_array($result)) {
228
+						foreach ($result as $key1=>$result1) {
229
+							if (is_array($result1)) {
230
+								  if ($deepPrinting) {
231
+									  echo "<br>$key1 ------><br>";
232
+									  Route4Me::simplePrint($result1, true);
233
+									  echo "------<br>";
234
+								  } else {
235
+									  echo $key1." --> "."Array() <br>";
236
+								  } 
237
+							} else {
238
+								if (is_object($result1)) {
239
+									if ($deepPrinting) {
240
+										echo "<br>$key1 ------><br>";
241
+										$oarray = (array)$result1;
242
+										Route4Me::simplePrint($oarray, true);
243
+										echo "------<br>";
244
+									} else {
245
+										echo $key1." --> "."Object <br>";
246
+									} 
247
+								} else {
248
+									if (!is_null($result1)) {
249
+										echo $key1." --> ".$result1."<br>"; 
250
+									}   
251
+								}
252
+							}
253
+						}
254
+					} else {
255
+						if (is_object($result)) {
256
+							if ($deepPrinting) {
257
+								echo "<br>$key ------><br>";
258
+								$oarray = (array)$result;
259
+								Route4Me::simplePrint($oarray, true);
260
+								echo "------<br>";
261
+							} else {
262
+								echo $key." --> "."Object <br>";
263
+							} 
264
+						} else {
265
+							if (!is_null($result)) {
266
+								echo $key." --> ".$result."<br>";
267
+							}
268
+						}
269 269
                         
270
-                    }
271
-                    //echo "<br>";
272
-                }
273
-            } 
274
-        }
275
-    }
270
+					}
271
+					//echo "<br>";
272
+				}
273
+			} 
274
+		}
275
+	}
276 276
 
277
-    /**
278
-     * Generates query or body parameters.
279
-     * @param $allFields: all known fields could be used for parameters generation.
280
-     * @param $params: input parameters (array or object)
281
-     */
282
-    public static function generateRequestParameters($allFields, $params)
283
-    {
284
-        $generatedParams = array();
277
+	/**
278
+	 * Generates query or body parameters.
279
+	 * @param $allFields: all known fields could be used for parameters generation.
280
+	 * @param $params: input parameters (array or object)
281
+	 */
282
+	public static function generateRequestParameters($allFields, $params)
283
+	{
284
+		$generatedParams = array();
285 285
         
286
-        if (is_array($params)) {
287
-            foreach ($allFields as $field) {
288
-                if (isset($params[$field])) {
289
-                    $generatedParams[$field] = $params[$field];
290
-                }
291
-            }
292
-        } elseif (is_object($params)) {
293
-            foreach ($allFields as $field) {
294
-                if (isset($params->{$field})) {
295
-                    $generatedParams[$field] = $params->{$field};
296
-                }
297
-            }
298
-        }
286
+		if (is_array($params)) {
287
+			foreach ($allFields as $field) {
288
+				if (isset($params[$field])) {
289
+					$generatedParams[$field] = $params[$field];
290
+				}
291
+			}
292
+		} elseif (is_object($params)) {
293
+			foreach ($allFields as $field) {
294
+				if (isset($params->{$field})) {
295
+					$generatedParams[$field] = $params->{$field};
296
+				}
297
+			}
298
+		}
299 299
 
300
-        return $generatedParams;
301
-    }
300
+		return $generatedParams;
301
+	}
302 302
     
303
-    /**
304
-     * Returns an array of the object properties
305
-     * @param $object: An object.
306
-     * @param $exclude: array of the object parameters to be excluded from the returned array.
307
-     */
308
-    public static function getObjectProperties($object, $exclude)
309
-    {
310
-        $objectParameters = array();
303
+	/**
304
+	 * Returns an array of the object properties
305
+	 * @param $object: An object.
306
+	 * @param $exclude: array of the object parameters to be excluded from the returned array.
307
+	 */
308
+	public static function getObjectProperties($object, $exclude)
309
+	{
310
+		$objectParameters = array();
311 311
         
312
-        foreach (get_object_vars($object) as $key => $value) {
313
-            if (property_exists($object, $key)) {
314
-                if (!is_numeric(array_search($key, $exclude))) {
315
-                    array_push($objectParameters, $key);
316
-                }
317
-            }
318
-        }
312
+		foreach (get_object_vars($object) as $key => $value) {
313
+			if (property_exists($object, $key)) {
314
+				if (!is_numeric(array_search($key, $exclude))) {
315
+					array_push($objectParameters, $key);
316
+				}
317
+			}
318
+		}
319 319
         
320
-        return $objectParameters;
321
-    }
320
+		return $objectParameters;
321
+	}
322 322
     
323
-    /**
324
-     * Returns url path generated from the array of the fields and parameters.
325
-     * @param $allFields; array of the paossible fields (parameter names).
326
-     * @param $params: input parameters (array or object).
327
-     */
328
-    public static function generateUrlPath($allFields, $params)
329
-    {
330
-        $generatedPath = "";
323
+	/**
324
+	 * Returns url path generated from the array of the fields and parameters.
325
+	 * @param $allFields; array of the paossible fields (parameter names).
326
+	 * @param $params: input parameters (array or object).
327
+	 */
328
+	public static function generateUrlPath($allFields, $params)
329
+	{
330
+		$generatedPath = "";
331 331
 
332
-        if (is_array($params)) {
333
-            foreach ($allFields as $field) {
334
-                if (isset($params[$field])) {
335
-                    $generatedPath .= $params[$field].'/';
336
-                }
337
-            }
338
-        } elseif (is_object($params)) {
339
-            foreach ($allFields as $field) {
340
-                if (isset($params->{$field})) {
341
-                    $generatedPath .= $params->{$field}.'/';
342
-                }
343
-            }
344
-        }
332
+		if (is_array($params)) {
333
+			foreach ($allFields as $field) {
334
+				if (isset($params[$field])) {
335
+					$generatedPath .= $params[$field].'/';
336
+				}
337
+			}
338
+		} elseif (is_object($params)) {
339
+			foreach ($allFields as $field) {
340
+				if (isset($params->{$field})) {
341
+					$generatedPath .= $params->{$field}.'/';
342
+				}
343
+			}
344
+		}
345 345
         
346
-        return $generatedPath;
347
-    }
346
+		return $generatedPath;
347
+	}
348 348
 }
Please login to merge, or discard this patch.
src/Route4Me/Geocoding.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -6,109 +6,109 @@
 block discarded – undo
6 6
 
7 7
 class Geocoding extends Common
8 8
 {
9
-    public $strExportFormat;
10
-    public $format;
11
-    public $addresses;
12
-    public $pk;
13
-    public $offset;
14
-    public $limit;
15
-    public $housenumber;
16
-    public $zipcode;
9
+	public $strExportFormat;
10
+	public $format;
11
+	public $addresses;
12
+	public $pk;
13
+	public $offset;
14
+	public $limit;
15
+	public $housenumber;
16
+	public $zipcode;
17 17
     
18
-    public static function fromArray(array $params) 
19
-    {
20
-        $geocoding = new Geocoding();
18
+	public static function fromArray(array $params) 
19
+	{
20
+		$geocoding = new Geocoding();
21 21
         
22
-        foreach($params as $key => $value) {
23
-            if (property_exists($geocoding, $key)) {
24
-                $geocoding->{$key} = $value;
25
-            }
26
-        }
22
+		foreach($params as $key => $value) {
23
+			if (property_exists($geocoding, $key)) {
24
+				$geocoding->{$key} = $value;
25
+			}
26
+		}
27 27
         
28
-        return $geocoding;
29
-    }
28
+		return $geocoding;
29
+	}
30 30
     
31
-    public static function forwardGeocoding($params)
32
-    {
33
-        $allBodyFields = array('strExportFormat', 'addresses');
31
+	public static function forwardGeocoding($params)
32
+	{
33
+		$allBodyFields = array('strExportFormat', 'addresses');
34 34
 
35
-        $fgCoding = Route4Me::makeRequst(array(
36
-            'url'    => Endpoint::GEOCODER,
37
-            'method' => 'POST',
38
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
39
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
40
-        ));
35
+		$fgCoding = Route4Me::makeRequst(array(
36
+			'url'    => Endpoint::GEOCODER,
37
+			'method' => 'POST',
38
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
39
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
40
+		));
41 41
         
42
-        return $fgCoding;
43
-    }
42
+		return $fgCoding;
43
+	}
44 44
     
45
-    public static function reverseGeocoding($params)
46
-    {
47
-        $allQueryFields = array('format', 'addresses', 'detailed');
45
+	public static function reverseGeocoding($params)
46
+	{
47
+		$allQueryFields = array('format', 'addresses', 'detailed');
48 48
 
49
-        $fgcoding = Route4Me::makeRequst(array(
50
-            'url'    => Endpoint::GEOCODER,
51
-            'method' => 'POST',
52
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
53
-        ));
49
+		$fgcoding = Route4Me::makeRequst(array(
50
+			'url'    => Endpoint::GEOCODER,
51
+			'method' => 'POST',
52
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
53
+		));
54 54
         
55
-        return $fgcoding;
56
-    }
55
+		return $fgcoding;
56
+	}
57 57
     
58
-    public static function getStreetData($params)
59
-    {
60
-        Route4Me::setBaseUrl(Endpoint::STREET_DATA);
58
+	public static function getStreetData($params)
59
+	{
60
+		Route4Me::setBaseUrl(Endpoint::STREET_DATA);
61 61
 
62
-        $allPathFields = array('pk', 'offset', 'limit');
62
+		$allPathFields = array('pk', 'offset', 'limit');
63 63
 
64
-        $url_query = Route4Me::generateUrlPath($allPathFields, $params);
64
+		$url_query = Route4Me::generateUrlPath($allPathFields, $params);
65 65
 
66
-        $query = array();
66
+		$query = array();
67 67
 
68
-        $response = Route4Me::makeRequst(array(
69
-            'url'    => $url_query,
70
-            'method' => 'GET',
71
-            'query'  => $query
72
-        ));
68
+		$response = Route4Me::makeRequst(array(
69
+			'url'    => $url_query,
70
+			'method' => 'GET',
71
+			'query'  => $query
72
+		));
73 73
 
74
-        return $response;
75
-    }
74
+		return $response;
75
+	}
76 76
     
77
-    public static function getZipCode($params)
78
-    {
79
-        Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE);
77
+	public static function getZipCode($params)
78
+	{
79
+		Route4Me::setBaseUrl(Endpoint::STREET_DATA_ZIPCODE);
80 80
 
81
-        $allPathFields = array('zipcode', 'offset', 'limit');
81
+		$allPathFields = array('zipcode', 'offset', 'limit');
82 82
 
83
-        $url_query = Route4Me::generateUrlPath($allPathFields, $params);
83
+		$url_query = Route4Me::generateUrlPath($allPathFields, $params);
84 84
 
85
-        $query = array();
85
+		$query = array();
86 86
 
87
-        $response = Route4Me::makeRequst(array(
88
-            'url'    => $url_query,
89
-            'method' => 'GET',
90
-            'query'  => $query
91
-        ));
87
+		$response = Route4Me::makeRequst(array(
88
+			'url'    => $url_query,
89
+			'method' => 'GET',
90
+			'query'  => $query
91
+		));
92 92
 
93
-        return $response;
94
-    }
93
+		return $response;
94
+	}
95 95
     
96
-    public static function getService($params)
97
-    {
98
-        Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE);
96
+	public static function getService($params)
97
+	{
98
+		Route4Me::setBaseUrl(Endpoint::STREET_DATA_SERVICE);
99 99
         
100
-        $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit');
100
+		$allPathFields = array('zipcode', 'housenumber', 'offset', 'limit');
101 101
 
102
-        $url_query = Route4Me::generateUrlPath($allPathFields, $params);
102
+		$url_query = Route4Me::generateUrlPath($allPathFields, $params);
103 103
         
104
-        $query = array();
104
+		$query = array();
105 105
         
106
-        $response = Route4Me::makeRequst(array(
107
-            'url'    => $url_query,
108
-            'method' => 'GET',
109
-            'query'  => $query
110
-        ));
106
+		$response = Route4Me::makeRequst(array(
107
+			'url'    => $url_query,
108
+			'method' => 'GET',
109
+			'query'  => $query
110
+		));
111 111
         
112
-        return $response;
113
-    }
112
+		return $response;
113
+	}
114 114
 }
Please login to merge, or discard this patch.