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.
Completed
Branch Editing-Fixing (c4d168)
by Igor
03:30
created
examples/multiple_depot_multiple_driver.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,20 +22,20 @@
 block discarded – undo
22 22
 
23 23
 $addresses = array();
24 24
 foreach($json as $address) {
25
-    $addresses[] = Address::fromArray($address);
25
+	$addresses[] = Address::fromArray($address);
26 26
 }
27 27
 
28 28
 $parameters = RouteParameters::fromArray(array(
29
-    "algorithm_type"          => AlgorithmType::CVRP_TW_SD,
30
-    "distance_unit"           => DistanceUnit::MILES,
31
-    "device_type"             => DeviceType::WEB,
32
-    "optimize"                => OptimizationType::DISTANCE,
33
-    "metric"                  => Metric::GEODESIC,
34
-    "route_max_duration"      => 86400 * 2,
35
-    "travel_mode"             => TravelMode::DRIVING,
36
-    "vehicle_capacity"        => 50,
37
-    "vehicle_max_distance_mi" => 10000,
38
-    "parts"                   => 50
29
+	"algorithm_type"          => AlgorithmType::CVRP_TW_SD,
30
+	"distance_unit"           => DistanceUnit::MILES,
31
+	"device_type"             => DeviceType::WEB,
32
+	"optimize"                => OptimizationType::DISTANCE,
33
+	"metric"                  => Metric::GEODESIC,
34
+	"route_max_duration"      => 86400 * 2,
35
+	"travel_mode"             => TravelMode::DRIVING,
36
+	"vehicle_capacity"        => 50,
37
+	"vehicle_max_distance_mi" => 10000,
38
+	"parts"                   => 50
39 39
 ));
40 40
 
41 41
 $optimizationParams = new OptimizationProblemParams;
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
@@ -23,18 +23,18 @@
 block discarded – undo
23 23
 
24 24
 $addresses = array();
25 25
 foreach($json as $address) {
26
-    $addresses[] = Address::fromArray($address);
26
+	$addresses[] = Address::fromArray($address);
27 27
 }
28 28
 
29 29
 $parameters = RouteParameters::fromArray(array(
30
-    "algorithm_type"          => AlgorithmType::TSP,
31
-    "distance_unit"           => DistanceUnit::MILES,
32
-    "device_type"             => DeviceType::WEB,
33
-    "optimize"                => OptimizationType::DISTANCE,
34
-    "travel_mode"             => TravelMode::DRIVING,
35
-    "route_max_duration"      => 86400,
36
-    "vehicle_capacity"        => 1,
37
-    "vehicle_max_distance_mi" => 10000
30
+	"algorithm_type"          => AlgorithmType::TSP,
31
+	"distance_unit"           => DistanceUnit::MILES,
32
+	"device_type"             => DeviceType::WEB,
33
+	"optimize"                => OptimizationType::DISTANCE,
34
+	"travel_mode"             => TravelMode::DRIVING,
35
+	"route_max_duration"      => 86400,
36
+	"vehicle_capacity"        => 1,
37
+	"vehicle_max_distance_mi" => 10000
38 38
 ));
39 39
 
40 40
 $optimizationParams = new OptimizationProblemParams;
Please login to merge, or discard this patch.
examples/Vehicles/get_vehicles.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 	
4 4
 	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 
6
-    require $vdir.'/../vendor/autoload.php';
6
+	require $vdir.'/../vendor/autoload.php';
7 7
 	
8 8
 	use Route4Me\Route4Me;
9 9
 	use Route4Me\Vehicle;
Please login to merge, or discard this patch.
src/Route4Me/Enum/Avoid.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class Avoidance
6 6
 {
7
-    const HIGHWAYS = 'Highways';
8
-    const TOLLS = 'Tolls';
9
-    const MINIMIZE_HIGHWAYS = 'minimizeHighways';
10
-    const MINIMIZE_TOLLS = 'minimizeTolls';
7
+	const HIGHWAYS = 'Highways';
8
+	const TOLLS = 'Tolls';
9
+	const MINIMIZE_HIGHWAYS = 'minimizeHighways';
10
+	const MINIMIZE_TOLLS = 'minimizeTolls';
11 11
 }
Please login to merge, or discard this patch.
src/Route4Me/Enum/DistanceUnit.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 class DistanceUnit
6 6
 {
7
-    const MILES = 'mi';
8
-    const KILOMETERS = 'km';
7
+	const MILES = 'mi';
8
+	const KILOMETERS = 'km';
9 9
 }
Please login to merge, or discard this patch.
src/Route4Me/Enum/Format.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 
5 5
 class Format
6 6
 {
7
-    const SERIALIZED = 'serialized';
8
-    const CSV = 'csv';
9
-    const XML = 'xml';
10
-    const JSON = 'json';
7
+	const SERIALIZED = 'serialized';
8
+	const CSV = 'csv';
9
+	const XML = 'xml';
10
+	const JSON = 'json';
11 11
 }
Please login to merge, or discard this patch.
src/Route4Me/TrackSetParams.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -9,102 +9,102 @@
 block discarded – undo
9 9
 
10 10
 class TrackSetParams extends Common
11 11
 {
12
-    public $format;
13
-    public $member_id;
14
-    public $route_id;
15
-    public $tx_id;
16
-    public $vehicle_id;
17
-    public $course;
18
-    public $speed;
19
-    public $lat;
20
-    public $lng;
21
-    public $altitude;
22
-    public $device_type;
23
-    public $device_guid;
24
-    public $device_timestamp;
25
-    public $app_version;
26
-
27
-    public static function fromArray(array $params)
28
-    {
29
-        $param = new TrackSetParams;
30
-
31
-        if (!isset($params['format'])) {
32
-            throw new BadParam("format must be provided.");
33
-        }
34
-
35
-        $types = array(
36
-            Format::SERIALIZED,
37
-            Format::CSV,
38
-            Format::XML
39
-        );
40
-        if (!in_array($params['format'], $types)) {
41
-            throw new BadParam("format is invalid.");
42
-        }
43
-
44
-        if (!isset($params['route_id'])) {
45
-            throw new BadParam("route_id must be provided.");
46
-        }
47
-
48
-        if (!isset($params['member_id'])) {
49
-            throw new BadParam("member_id must be provided.");
50
-        }
51
-
52
-        if (!isset($params['course'])) {
53
-            throw new BadParam("course must be provided.");
54
-        }
55
-
56
-        if (!isset($params['speed'])) {
57
-            throw new BadParam("speed must be provided.");
58
-        }
59
-
60
-        if (!isset($params['lat'])) {
61
-            throw new BadParam("lat must be provided.");
62
-        }
63
-
64
-        if (!isset($params['lng'])) {
65
-            throw new BadParam("lng must be provided.");
66
-        }
67
-
68
-        if (!isset($params['device_type'])) {
69
-            throw new BadParam("device_type must be provided.");
70
-        }
71
-
72
-        $deviceTypes = array(
73
-            DeviceType::IPHONE,
74
-            DeviceType::IPAD,
75
-            DeviceType::ANDROID_PHONE,
76
-            DeviceType::ANDROID_TABLET
77
-        );
78
-        if (!in_array($params['device_type'], $deviceTypes)) {
79
-            throw new BadParam("device_type is invalid.");
80
-        }
81
-
82
-        if (!isset($params['device_guid'])) {
83
-            throw new BadParam("device_guid must be provided.");
84
-        }
85
-
86
-        if (isset($params['device_timestamp'])) {
87
-            $template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i';
88
-            if (!preg_match($template, $params['device_timestamp'])) {
89
-                throw new BadParam("device_timestamp is invalid.");
90
-            }
91
-        }
92
-
93
-        $param->format = self::getValue($params, 'format');
94
-        $param->route_id = self::getValue($params, 'route_id');
95
-        $param->member_id = self::getValue($params, 'member_id');
96
-        $param->course = self::getValue($params, 'course');
97
-        $param->speed = self::getValue($params, 'speed');
98
-        $param->lat = self::getValue($params, 'lat');
99
-        $param->lng = self::getValue($params, 'lng');
100
-        $param->device_type = self::getValue($params, 'device_type');
101
-        $param->device_guid = self::getValue($params, 'device_guid');
102
-        $param->device_timestamp = self::getValue($params, 'device_timestamp');
103
-        $param->vehicle_id = self::getValue($params, 'vehicle_id');
104
-        $param->altitude = self::getValue($params, 'altitude');
105
-        $param->app_version = self::getValue($params, 'app_version');
106
-        $param->tx_id = self::getValue($params, 'tx_id');
107
-
108
-        return $param;
109
-    }
12
+	public $format;
13
+	public $member_id;
14
+	public $route_id;
15
+	public $tx_id;
16
+	public $vehicle_id;
17
+	public $course;
18
+	public $speed;
19
+	public $lat;
20
+	public $lng;
21
+	public $altitude;
22
+	public $device_type;
23
+	public $device_guid;
24
+	public $device_timestamp;
25
+	public $app_version;
26
+
27
+	public static function fromArray(array $params)
28
+	{
29
+		$param = new TrackSetParams;
30
+
31
+		if (!isset($params['format'])) {
32
+			throw new BadParam("format must be provided.");
33
+		}
34
+
35
+		$types = array(
36
+			Format::SERIALIZED,
37
+			Format::CSV,
38
+			Format::XML
39
+		);
40
+		if (!in_array($params['format'], $types)) {
41
+			throw new BadParam("format is invalid.");
42
+		}
43
+
44
+		if (!isset($params['route_id'])) {
45
+			throw new BadParam("route_id must be provided.");
46
+		}
47
+
48
+		if (!isset($params['member_id'])) {
49
+			throw new BadParam("member_id must be provided.");
50
+		}
51
+
52
+		if (!isset($params['course'])) {
53
+			throw new BadParam("course must be provided.");
54
+		}
55
+
56
+		if (!isset($params['speed'])) {
57
+			throw new BadParam("speed must be provided.");
58
+		}
59
+
60
+		if (!isset($params['lat'])) {
61
+			throw new BadParam("lat must be provided.");
62
+		}
63
+
64
+		if (!isset($params['lng'])) {
65
+			throw new BadParam("lng must be provided.");
66
+		}
67
+
68
+		if (!isset($params['device_type'])) {
69
+			throw new BadParam("device_type must be provided.");
70
+		}
71
+
72
+		$deviceTypes = array(
73
+			DeviceType::IPHONE,
74
+			DeviceType::IPAD,
75
+			DeviceType::ANDROID_PHONE,
76
+			DeviceType::ANDROID_TABLET
77
+		);
78
+		if (!in_array($params['device_type'], $deviceTypes)) {
79
+			throw new BadParam("device_type is invalid.");
80
+		}
81
+
82
+		if (!isset($params['device_guid'])) {
83
+			throw new BadParam("device_guid must be provided.");
84
+		}
85
+
86
+		if (isset($params['device_timestamp'])) {
87
+			$template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i';
88
+			if (!preg_match($template, $params['device_timestamp'])) {
89
+				throw new BadParam("device_timestamp is invalid.");
90
+			}
91
+		}
92
+
93
+		$param->format = self::getValue($params, 'format');
94
+		$param->route_id = self::getValue($params, 'route_id');
95
+		$param->member_id = self::getValue($params, 'member_id');
96
+		$param->course = self::getValue($params, 'course');
97
+		$param->speed = self::getValue($params, 'speed');
98
+		$param->lat = self::getValue($params, 'lat');
99
+		$param->lng = self::getValue($params, 'lng');
100
+		$param->device_type = self::getValue($params, 'device_type');
101
+		$param->device_guid = self::getValue($params, 'device_guid');
102
+		$param->device_timestamp = self::getValue($params, 'device_timestamp');
103
+		$param->vehicle_id = self::getValue($params, 'vehicle_id');
104
+		$param->altitude = self::getValue($params, 'altitude');
105
+		$param->app_version = self::getValue($params, 'app_version');
106
+		$param->tx_id = self::getValue($params, 'tx_id');
107
+
108
+		return $param;
109
+	}
110 110
 }
Please login to merge, or discard this patch.
src/Route4Me/MyQ.php 2 patches
Unused Use Statements   +1 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Route4Me;
3 3
 
4
-use Route4Me\Common;
5
-/**
6
- * class MyQ
7
- *
8
- * Offers authentication to MyQ API, and access to garage door open/close/status functions
9
- *
10
- */
4
+
11 5
 class MyQException extends \Exception {}
12 6
 class MyQ {
13 7
     
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -11,213 +11,213 @@
 block discarded – undo
11 11
 class MyQException extends \Exception {}
12 12
 
13 13
 class MyQ {
14
-    /** @var string|null $username contains the username used to authenticate with the MyQ API */
15
-    protected $username = null;
16
-    /** @var string|null $password contains the password used to authenticate with the MyQ API */
17
-    protected $password = null;
18
-    /** @var string|null $appId is the application ID used to register with the MyQ API */
19
-    protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx';
20
-    //protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi';
21
-    /** @var string|null $securityToken is the auth token returned after a successful login */
22
-    protected $securityToken = null;
23
-    /** @var string|null $userAgent is the User-Agent header value sent with each API request */
24
-    protected $userAgent = 'Chamberlain/3.4.1';
25
-    /** @var string|null $culture is the API culture code for the API */
26
-    protected $culture = 'en';
27
-    /** @var string|null $contentType is the content type used for all cURL requests */
28
-    protected $contentType = 'application/json';
29
-    /** @var array $headers contain HTTP headers for cURL requests */
30
-    protected $_headers = array();
31
-    protected $_deviceId = null;
32
-    protected $_locationName = null;
33
-    protected $_doorName = null;
34
-    protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate';
35
-    protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true';
36
-    protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute';
37
-    /** @var resource|null $_conn is the web connection to the MyQ API */
38
-    protected $_conn = null;
14
+	/** @var string|null $username contains the username used to authenticate with the MyQ API */
15
+	protected $username = null;
16
+	/** @var string|null $password contains the password used to authenticate with the MyQ API */
17
+	protected $password = null;
18
+	/** @var string|null $appId is the application ID used to register with the MyQ API */
19
+	protected $appId = 'NWknvuBd7LoFHfXmKNMBcgajXtZEgKUh4V7WNzMidrpUUluDpVYVZx+xT4PCM5Kx';
20
+	//protected $appId = 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2fi';
21
+	/** @var string|null $securityToken is the auth token returned after a successful login */
22
+	protected $securityToken = null;
23
+	/** @var string|null $userAgent is the User-Agent header value sent with each API request */
24
+	protected $userAgent = 'Chamberlain/3.4.1';
25
+	/** @var string|null $culture is the API culture code for the API */
26
+	protected $culture = 'en';
27
+	/** @var string|null $contentType is the content type used for all cURL requests */
28
+	protected $contentType = 'application/json';
29
+	/** @var array $headers contain HTTP headers for cURL requests */
30
+	protected $_headers = array();
31
+	protected $_deviceId = null;
32
+	protected $_locationName = null;
33
+	protected $_doorName = null;
34
+	protected $_loginUrl = 'https://myqexternal.myqdevice.com/api/v4/User/Validate';
35
+	protected $_getDeviceDetailUrl = 'https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get?&filterOn=true';
36
+	protected $_putDeviceStateUrl = '/api/v4/DeviceAttribute/PutDeviceAttribute';
37
+	/** @var resource|null $_conn is the web connection to the MyQ API */
38
+	protected $_conn = null;
39 39
     
40
-    /**
41
-     * Initializes class. Optionally allows user to override variables
42
-     *
43
-     * @param array $params A associative array for overwriting class variables
44
-     *
45
-     * @return MyQ
46
-     */
47
-    public function __construct ($params = array())
48
-    {
49
-        // Overwrite class variables
50
-        foreach ($params as $k => $v) {
51
-            $this->$k = $v;
52
-        }
53
-        
54
-        // Initialize cURL request headers
55
-        if (sizeof($this->_headers) == 0) {
56
-            $this->_headers = array (
57
-                'MyQApplicationId' => $this->appId,
58
-                'Culture' => $this->culture,
59
-                'Content-Type' => $this->contentType,
60
-                'User-Agent' => $this->userAgent,
61
-            );
62
-        }
63
-        
64
-        // Initialize cURL connection
65
-        $this->_init();
66
-        
67
-        return $this;
68
-    }
40
+	/**
41
+	 * Initializes class. Optionally allows user to override variables
42
+	 *
43
+	 * @param array $params A associative array for overwriting class variables
44
+	 *
45
+	 * @return MyQ
46
+	 */
47
+	public function __construct ($params = array())
48
+	{
49
+		// Overwrite class variables
50
+		foreach ($params as $k => $v) {
51
+			$this->$k = $v;
52
+		}
53
+        
54
+		// Initialize cURL request headers
55
+		if (sizeof($this->_headers) == 0) {
56
+			$this->_headers = array (
57
+				'MyQApplicationId' => $this->appId,
58
+				'Culture' => $this->culture,
59
+				'Content-Type' => $this->contentType,
60
+				'User-Agent' => $this->userAgent,
61
+			);
62
+		}
63
+        
64
+		// Initialize cURL connection
65
+		$this->_init();
66
+        
67
+		return $this;
68
+	}
69 69
     
70
-    /**
71
-     * Perform a login request
72
-     *
73
-     * @param string|null $username Username to use when logging in
74
-     * @param string|null $password Password to use for logging in
75
-     *
76
-     * @return MyQ
77
-     */
78
-    public function login ($username = null, $password = null)
79
-    {
80
-        // Set username/password if not null
81
-        if (!is_null($username)) {
82
-            $this->username = $username;
83
-        }
84
-        
85
-        if (!is_null($password)) {
86
-            $this->password = $password;
87
-        }
88
-        
89
-        // confirm that we have a valid username/password
90
-        $error = array();
91
-        if (is_null($this->username)) {
92
-            $error[] = 'username';
93
-        }
94
-        
95
-        if (is_null($this->password)) {
96
-            $error[] = 'password';
97
-        }
98
-        
99
-        if (sizeof($error) > 0) {
100
-            throw new MyQException('Missing required auth credential: ' . implode(',', $error));
101
-        }
102
-        
103
-        $this->_login();
104
-    }
70
+	/**
71
+	 * Perform a login request
72
+	 *
73
+	 * @param string|null $username Username to use when logging in
74
+	 * @param string|null $password Password to use for logging in
75
+	 *
76
+	 * @return MyQ
77
+	 */
78
+	public function login ($username = null, $password = null)
79
+	{
80
+		// Set username/password if not null
81
+		if (!is_null($username)) {
82
+			$this->username = $username;
83
+		}
84
+        
85
+		if (!is_null($password)) {
86
+			$this->password = $password;
87
+		}
88
+        
89
+		// confirm that we have a valid username/password
90
+		$error = array();
91
+		if (is_null($this->username)) {
92
+			$error[] = 'username';
93
+		}
94
+        
95
+		if (is_null($this->password)) {
96
+			$error[] = 'password';
97
+		}
98
+        
99
+		if (sizeof($error) > 0) {
100
+			throw new MyQException('Missing required auth credential: ' . implode(',', $error));
101
+		}
102
+        
103
+		$this->_login();
104
+	}
105 105
     
106
-    public function getState()
107
-    {
108
-        $this->_getDetails();
109
-        $timeInState = time() - $this->_doorStateTime;
110
-        echo implode(',', array (
111
-            $this->_locationName,
112
-            $this->_doorName,
113
-            $this->_doorState,
114
-            (int)$timeInState,
115
-        ));
116
-    }
106
+	public function getState()
107
+	{
108
+		$this->_getDetails();
109
+		$timeInState = time() - $this->_doorStateTime;
110
+		echo implode(',', array (
111
+			$this->_locationName,
112
+			$this->_doorName,
113
+			$this->_doorState,
114
+			(int)$timeInState,
115
+		));
116
+	}
117 117
     
118
-    public function getDetails()
119
-    {
120
-        return $this->_getDetails();
121
-    }
118
+	public function getDetails()
119
+	{
120
+		return $this->_getDetails();
121
+	}
122 122
     
123
-    private function _init()
124
-    {
125
-        if (!isset($this->_conn)) {
126
-            $this->_conn = curl_init();
123
+	private function _init()
124
+	{
125
+		if (!isset($this->_conn)) {
126
+			$this->_conn = curl_init();
127 127
             
128
-            curl_setopt_array($this->_conn, array (
129
-                CURLOPT_RETURNTRANSFER => true,
130
-                CURLOPT_ENCODING       => "",
131
-                CURLOPT_MAXREDIRS      => 10,
132
-                CURLOPT_TIMEOUT        => 30,
133
-                CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
134
-                CURLOPT_FAILONERROR    => true,
135
-                CURLOPT_FOLLOWLOCATION => true,
136
-                CURLOPT_FRESH_CONNECT  => true,
137
-                CURLOPT_FORBID_REUSE   => true,
138
-                CURLOPT_USERAGENT      => $this->userAgent,
139
-            ));
140
-        }
141
-        
142
-        $this->_setHeaders();
143
-    }
144
-    private function _setHeaders()
145
-    {
146
-        $headers = array();
147
-        
148
-        foreach ($this->_headers as $k => $v) {
149
-            $headers[] = "$k: $v";
150
-        }
151
-        
152
-        curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
153
-    }
128
+			curl_setopt_array($this->_conn, array (
129
+				CURLOPT_RETURNTRANSFER => true,
130
+				CURLOPT_ENCODING       => "",
131
+				CURLOPT_MAXREDIRS      => 10,
132
+				CURLOPT_TIMEOUT        => 30,
133
+				CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
134
+				CURLOPT_FAILONERROR    => true,
135
+				CURLOPT_FOLLOWLOCATION => true,
136
+				CURLOPT_FRESH_CONNECT  => true,
137
+				CURLOPT_FORBID_REUSE   => true,
138
+				CURLOPT_USERAGENT      => $this->userAgent,
139
+			));
140
+		}
141
+        
142
+		$this->_setHeaders();
143
+	}
144
+	private function _setHeaders()
145
+	{
146
+		$headers = array();
147
+        
148
+		foreach ($this->_headers as $k => $v) {
149
+			$headers[] = "$k: $v";
150
+		}
151
+        
152
+		curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
153
+	}
154 154
     
155
-    private function _login()
156
-    {
157
-        $this->_init();
155
+	private function _login()
156
+	{
157
+		$this->_init();
158 158
         
159
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
160
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
159
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
160
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
161 161
         
162
-        $post = json_encode(array('username' => $this->username, 'password' => $this->password));
162
+		$post = json_encode(array('username' => $this->username, 'password' => $this->password));
163 163
         
164
-        curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
164
+		curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
165 165
         
166
-        $output = curl_exec($this->_conn);
166
+		$output = curl_exec($this->_conn);
167 167
         
168
-        $data = json_decode($output);
168
+		$data = json_decode($output);
169 169
         
170
-        if ($data == false || !isset($data->SecurityToken)) {
171
-            throw new MyQException("Error processing login request: $output");
172
-        }
170
+		if ($data == false || !isset($data->SecurityToken)) {
171
+			throw new MyQException("Error processing login request: $output");
172
+		}
173 173
         
174
-        $this->_headers['SecurityToken'] = $data->SecurityToken;
174
+		$this->_headers['SecurityToken'] = $data->SecurityToken;
175 175
         
176
-        return $this;
177
-    }
176
+		return $this;
177
+	}
178 178
     
179
-    private function _getDetails()
180
-    {
181
-        $this->_init();
182
-        
183
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
184
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
185
-        
186
-        $output = curl_exec($this->_conn);
187
-        
188
-        $data = json_decode($output);
189
-        
190
-        if ($data == false || !isset($data->Devices)) {
191
-            throw new MyQException("Error fetching device details: $output");
192
-        }
193
-        
194
-        // Find our door device ID
195
-        foreach ($data->Devices as $device) {
196
-            if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
197
-                // Find location name
198
-                foreach ($device->Attributes as $attr) {
199
-                    if ($attr->AttributeDisplayName == 'desc') {
200
-                        $this->_locationName = $attr->Value;
201
-                    }
202
-                }
203
-            }
179
+	private function _getDetails()
180
+	{
181
+		$this->_init();
182
+        
183
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
184
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
185
+        
186
+		$output = curl_exec($this->_conn);
187
+        
188
+		$data = json_decode($output);
189
+        
190
+		if ($data == false || !isset($data->Devices)) {
191
+			throw new MyQException("Error fetching device details: $output");
192
+		}
193
+        
194
+		// Find our door device ID
195
+		foreach ($data->Devices as $device) {
196
+			if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
197
+				// Find location name
198
+				foreach ($device->Attributes as $attr) {
199
+					if ($attr->AttributeDisplayName == 'desc') {
200
+						$this->_locationName = $attr->Value;
201
+					}
202
+				}
203
+			}
204 204
             
205
-            $this->_deviceId = $device->MyQDeviceId;
205
+			$this->_deviceId = $device->MyQDeviceId;
206 206
             
207
-            foreach ($device->Attributes as $attr) {
208
-                switch ($attr->AttributeDisplayName) {
209
-                    case 'desc':
210
-                        $this->_doorName = $attr->Value;
211
-                        break;
212
-                    case 'doorstate':
213
-                        $this->_doorState = $attr->Value;
214
-                        // UpdatedTime is a timestamp in ms, so we truncate
215
-                        $this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
216
-                        break;
217
-                    default:
218
-                        continue;
219
-                }
220
-            }
221
-        }
222
-    }
207
+			foreach ($device->Attributes as $attr) {
208
+				switch ($attr->AttributeDisplayName) {
209
+					case 'desc':
210
+						$this->_doorName = $attr->Value;
211
+						break;
212
+					case 'doorstate':
213
+						$this->_doorState = $attr->Value;
214
+						// UpdatedTime is a timestamp in ms, so we truncate
215
+						$this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
216
+						break;
217
+					default:
218
+						continue;
219
+				}
220
+			}
221
+		}
222
+	}
223 223
 }
Please login to merge, or discard this patch.
examples/Optimizations/hybridOptimization.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 require $root . '/vendor/autoload.php';
6 6
 
7 7
 use Route4Me\OptimizationProblem;
8
-use Route4Me\Route;
9 8
 use Route4Me\Route4Me;
10 9
 
11 10
 /* The example demonstrates process of creating a Hybrid Optimization using scheduling addresses and orders.
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
 $locationsFieldsMapping['monthly_nth_wwhat'] = 17;
46 46
 
47 47
 if (($handle = fopen("$source_file", "r")) !== FALSE) {
48
-        $oAbook = new AddressBookLocation();
48
+		$oAbook = new AddressBookLocation();
49 49
 
50
-        $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
50
+		$results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
51 51
         
52
-        echo "Errors: <br><br>";
52
+		echo "Errors: <br><br>";
53 53
         
54
-        foreach ($results['fail'] as $evalue) {
55
-            echo $evalue."<br>";
56
-        }
54
+		foreach ($results['fail'] as $evalue) {
55
+			echo $evalue."<br>";
56
+		}
57 57
         
58
-        echo "Successes: <br><br>";
58
+		echo "Successes: <br><br>";
59 59
         
60
-        foreach ($results['success'] as $svalue) {
61
-            echo $svalue."<br>";
62
-        }
63
-    }
60
+		foreach ($results['success'] as $svalue) {
61
+			echo $svalue."<br>";
62
+		}
63
+	}
64 64
 
65 65
 /* Add orders with schedules from a CSV file  */
66 66
 
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8;
80 80
 
81 81
 if (($handle = fopen("$orders_file", "r")) !== FALSE) {
82
-    $order = new Order();
83
-    $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
82
+	$order = new Order();
83
+	$results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
84 84
     
85
-    echo "Errors: <br><br>";
85
+	echo "Errors: <br><br>";
86 86
     
87
-    foreach ($results['fail'] as $evalue) {
88
-        echo $evalue."<br>";
89
-    }
87
+	foreach ($results['fail'] as $evalue) {
88
+		echo $evalue."<br>";
89
+	}
90 90
     
91
-    echo "Successes: <br><br>";
91
+	echo "Successes: <br><br>";
92 92
     
93
-    foreach ($results['success'] as $svalue) {
94
-        echo $svalue."<br>";
95
-    }
93
+	foreach ($results['success'] as $svalue) {
94
+		echo $svalue."<br>";
95
+	}
96 96
 }
97 97
 
98 98
 /* Get Hybrid Optimization */
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
 $sched_date = date("Y-m-d", $ep);
102 102
 
103 103
 $hybridParams = array(
104
-    "target_date_string" => $sched_date,
105
-    "timezone_offset_minutes" => 480
104
+	"target_date_string" => $sched_date,
105
+	"timezone_offset_minutes" => 480
106 106
 );
107 107
 
108 108
 $optimization = new OptimizationProblem(); 
109 109
 $hybridOptimization = $optimization->getHybridOptimization($hybridParams);
110 110
 
111 111
 if ($hybridOptimization!=null) {
112
-    if (isset($hybridOptimization['optimization_problem_id'])) {
113
-        $optid = $hybridOptimization['optimization_problem_id'];
112
+	if (isset($hybridOptimization['optimization_problem_id'])) {
113
+		$optid = $hybridOptimization['optimization_problem_id'];
114 114
         
115
-        echo "Hibrid optimization with optimization_problem_id = $optid <br><br>";
115
+		echo "Hibrid optimization with optimization_problem_id = $optid <br><br>";
116 116
         
117
-        /* Add depots to the Hybrid Optimization */
118
-        $depotfile = "depots.csv";
117
+		/* Add depots to the Hybrid Optimization */
118
+		$depotfile = "depots.csv";
119 119
         
120
-        if (($handle = fopen("$depotfile", "r")) !== FALSE) {
121
-            $columns = fgetcsv($handle, $max_line_length, $delemietr);
120
+		if (($handle = fopen("$depotfile", "r")) !== FALSE) {
121
+			$columns = fgetcsv($handle, $max_line_length, $delemietr);
122 122
             
123
-            if (!$columns) {
124
-                $error['message'] = 'Empty';
125
-                 return ($error);
126
-            }
123
+			if (!$columns) {
124
+				$error['message'] = 'Empty';
125
+				 return ($error);
126
+			}
127 127
             
128
-            $depotsParams = array(
129
-                'optimization_problem_id' => $optid,
130
-                'delete_old_depots'       => true,
131
-            );
128
+			$depotsParams = array(
129
+				'optimization_problem_id' => $optid,
130
+				'delete_old_depots'       => true,
131
+			);
132 132
             
133
-            $iRow = 1;
134
-            $depotAddresses = array();
133
+			$iRow = 1;
134
+			$depotAddresses = array();
135 135
             
136
-            while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
137
-                if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
138
-                    $depotAddress['lat'] = $rows[0];
139
-                    $depotAddress['lng'] = $rows[1];
140
-                    $depotAddress['address'] = $rows[3];   
141
-                    array_push($depotAddresses,$depotAddress);
142
-                }
143
-            }
136
+			while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
137
+				if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
138
+					$depotAddress['lat'] = $rows[0];
139
+					$depotAddress['lng'] = $rows[1];
140
+					$depotAddress['address'] = $rows[3];   
141
+					array_push($depotAddresses,$depotAddress);
142
+				}
143
+			}
144 144
             
145
-            $depotsParams['new_depots'] = $depotAddresses;
145
+			$depotsParams['new_depots'] = $depotAddresses;
146 146
             
147
-            $optProblem = new OptimizationProblem();
147
+			$optProblem = new OptimizationProblem();
148 148
             
149
-            $resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
149
+			$resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
150 150
             
151
-            var_dump($resultDepots);
151
+			var_dump($resultDepots);
152 152
             
153
-            /* Reoptimize hybrid optimization */
153
+			/* Reoptimize hybrid optimization */
154 154
             
155
-            if ($resultDepots != null) {
156
-                $problemParams = array(
157
-                    'optimization_problem_id'  =>  $optid
158
-                );
159
-                $problem = OptimizationProblem::reoptimize($problemParams);
155
+			if ($resultDepots != null) {
156
+				$problemParams = array(
157
+					'optimization_problem_id'  =>  $optid
158
+				);
159
+				$problem = OptimizationProblem::reoptimize($problemParams);
160 160
                 
161
-                Route4Me::simplePrint($problem);
162
-            }
163
-        }
164
-    }
161
+				Route4Me::simplePrint($problem);
162
+			}
163
+		}
164
+	}
165 165
 }
Please login to merge, or discard this patch.