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
Push — master ( ae3ad2...c1f900 )
by
unknown
05:02
created
src/Route4Me/MyQ.php 4 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   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -11,174 +11,174 @@
 block discarded – undo
11 11
 class MyQException extends \Exception {}
12 12
 class MyQ {
13 13
     
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
-    /**
40
-     * Initializes class. Optionally allows user to override variables
41
-     *
42
-     * @param array $params A associative array for overwriting class variables
43
-     *
44
-     * @return MyQ
45
-     */
46
-    public function __construct ($params = array()) {
47
-        // Overwrite class variables
48
-        foreach ($params as $k => $v) {
49
-            $this->$k = $v;
50
-        }
51
-        // Initialize cURL request headers
52
-        if (sizeof($this->_headers) == 0) {
53
-            $this->_headers = array (
54
-                'MyQApplicationId' => $this->appId,
55
-                'Culture' => $this->culture,
56
-                'Content-Type' => $this->contentType,
57
-                'User-Agent' => $this->userAgent,
58
-            );
59
-        }
60
-        // Initialize cURL connection
61
-        $this->_init();
62
-        return $this;
63
-    }
64
-    /**
65
-     * Perform a login request
66
-     *
67
-     * @param string|null $username Username to use when logging in
68
-     * @param string|null $password Password to use for logging in
69
-     *
70
-     * @return MyQ
71
-     */
72
-    public function login ($username = null, $password = null) {
73
-        // Set username/password if not null
74
-        if (!is_null($username)) {
75
-            $this->username = $username;
76
-        }
77
-        if (!is_null($password)) {
78
-            $this->password = $password;
79
-        }
80
-        // confirm that we have a valid username/password
81
-        $error = array();
82
-        if (is_null($this->username)) {
83
-            $error[] = 'username';
84
-        }
85
-        if (is_null($this->password)) {
86
-            $error[] = 'password';
87
-        }
88
-        if (sizeof($error) > 0) {
89
-            throw new MyQException('Missing required auth credential: ' . implode(',', $error));
90
-        }
91
-        $this->_login();
92
-    }
93
-    public function getState () {
94
-        $this->_getDetails();
95
-        $timeInState = time() - $this->_doorStateTime;
96
-        echo implode(',', array (
97
-            $this->_locationName,
98
-            $this->_doorName,
99
-            $this->_doorState,
100
-            (int)$timeInState,
101
-        ));
102
-    }
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
+	/**
40
+	 * Initializes class. Optionally allows user to override variables
41
+	 *
42
+	 * @param array $params A associative array for overwriting class variables
43
+	 *
44
+	 * @return MyQ
45
+	 */
46
+	public function __construct ($params = array()) {
47
+		// Overwrite class variables
48
+		foreach ($params as $k => $v) {
49
+			$this->$k = $v;
50
+		}
51
+		// Initialize cURL request headers
52
+		if (sizeof($this->_headers) == 0) {
53
+			$this->_headers = array (
54
+				'MyQApplicationId' => $this->appId,
55
+				'Culture' => $this->culture,
56
+				'Content-Type' => $this->contentType,
57
+				'User-Agent' => $this->userAgent,
58
+			);
59
+		}
60
+		// Initialize cURL connection
61
+		$this->_init();
62
+		return $this;
63
+	}
64
+	/**
65
+	 * Perform a login request
66
+	 *
67
+	 * @param string|null $username Username to use when logging in
68
+	 * @param string|null $password Password to use for logging in
69
+	 *
70
+	 * @return MyQ
71
+	 */
72
+	public function login ($username = null, $password = null) {
73
+		// Set username/password if not null
74
+		if (!is_null($username)) {
75
+			$this->username = $username;
76
+		}
77
+		if (!is_null($password)) {
78
+			$this->password = $password;
79
+		}
80
+		// confirm that we have a valid username/password
81
+		$error = array();
82
+		if (is_null($this->username)) {
83
+			$error[] = 'username';
84
+		}
85
+		if (is_null($this->password)) {
86
+			$error[] = 'password';
87
+		}
88
+		if (sizeof($error) > 0) {
89
+			throw new MyQException('Missing required auth credential: ' . implode(',', $error));
90
+		}
91
+		$this->_login();
92
+	}
93
+	public function getState () {
94
+		$this->_getDetails();
95
+		$timeInState = time() - $this->_doorStateTime;
96
+		echo implode(',', array (
97
+			$this->_locationName,
98
+			$this->_doorName,
99
+			$this->_doorState,
100
+			(int)$timeInState,
101
+		));
102
+	}
103 103
 	
104 104
 	public function getDetails() {
105 105
 		return $this->_getDetails();
106 106
 	}
107 107
 	
108
-    private function _init () {
109
-        if (!isset($this->_conn)) {
110
-            $this->_conn = curl_init();
111
-            curl_setopt_array($this->_conn, array (
112
-                CURLOPT_RETURNTRANSFER => true,
113
-                CURLOPT_ENCODING => "",
114
-                CURLOPT_MAXREDIRS => 10,
115
-                CURLOPT_TIMEOUT => 30,
116
-                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
117
-                CURLOPT_FAILONERROR => true,
118
-                CURLOPT_FOLLOWLOCATION => true,
119
-                CURLOPT_FRESH_CONNECT => true,
120
-                CURLOPT_FORBID_REUSE => true,
121
-                CURLOPT_USERAGENT => $this->userAgent,
122
-            ));
123
-        }
124
-        $this->_setHeaders();
125
-    }
126
-    private function _setHeaders () {
127
-        $headers = array();
128
-        foreach ($this->_headers as $k => $v) {
129
-            $headers[] = "$k: $v";
130
-        }
131
-        curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
132
-    }
133
-    private function _login () {
134
-        $this->_init();
135
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
136
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
137
-        $post = json_encode(array('username' => $this->username, 'password' => $this->password));
138
-        curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
139
-        $output = curl_exec($this->_conn);
140
-        $data = json_decode($output);
141
-        if ($data == false || !isset($data->SecurityToken)) {
142
-            throw new MyQException("Error processing login request: $output");
143
-        }
144
-        $this->_headers['SecurityToken'] = $data->SecurityToken;
145
-        return $this;
146
-    }
147
-    private function _getDetails () {
148
-        $this->_init();
149
-        curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
150
-        curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
151
-        $output = curl_exec($this->_conn);
152
-        $data = json_decode($output);
153
-        if ($data == false || !isset($data->Devices)) {
154
-            throw new MyQException("Error fetching device details: $output");
155
-        }
156
-        // Find our door device ID
157
-        foreach ($data->Devices as $device) {
158
-            if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
159
-                // Find location name
160
-                foreach ($device->Attributes as $attr) {
161
-                    if ($attr->AttributeDisplayName == 'desc') {
162
-                        $this->_locationName = $attr->Value;
163
-                    }
164
-                }
165
-            }
108
+	private function _init () {
109
+		if (!isset($this->_conn)) {
110
+			$this->_conn = curl_init();
111
+			curl_setopt_array($this->_conn, array (
112
+				CURLOPT_RETURNTRANSFER => true,
113
+				CURLOPT_ENCODING => "",
114
+				CURLOPT_MAXREDIRS => 10,
115
+				CURLOPT_TIMEOUT => 30,
116
+				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
117
+				CURLOPT_FAILONERROR => true,
118
+				CURLOPT_FOLLOWLOCATION => true,
119
+				CURLOPT_FRESH_CONNECT => true,
120
+				CURLOPT_FORBID_REUSE => true,
121
+				CURLOPT_USERAGENT => $this->userAgent,
122
+			));
123
+		}
124
+		$this->_setHeaders();
125
+	}
126
+	private function _setHeaders () {
127
+		$headers = array();
128
+		foreach ($this->_headers as $k => $v) {
129
+			$headers[] = "$k: $v";
130
+		}
131
+		curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
132
+	}
133
+	private function _login () {
134
+		$this->_init();
135
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
136
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
137
+		$post = json_encode(array('username' => $this->username, 'password' => $this->password));
138
+		curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
139
+		$output = curl_exec($this->_conn);
140
+		$data = json_decode($output);
141
+		if ($data == false || !isset($data->SecurityToken)) {
142
+			throw new MyQException("Error processing login request: $output");
143
+		}
144
+		$this->_headers['SecurityToken'] = $data->SecurityToken;
145
+		return $this;
146
+	}
147
+	private function _getDetails () {
148
+		$this->_init();
149
+		curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
150
+		curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
151
+		$output = curl_exec($this->_conn);
152
+		$data = json_decode($output);
153
+		if ($data == false || !isset($data->Devices)) {
154
+			throw new MyQException("Error fetching device details: $output");
155
+		}
156
+		// Find our door device ID
157
+		foreach ($data->Devices as $device) {
158
+			if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
159
+				// Find location name
160
+				foreach ($device->Attributes as $attr) {
161
+					if ($attr->AttributeDisplayName == 'desc') {
162
+						$this->_locationName = $attr->Value;
163
+					}
164
+				}
165
+			}
166 166
             
167
-            $this->_deviceId = $device->MyQDeviceId;
168
-            foreach ($device->Attributes as $attr) {
169
-                switch ($attr->AttributeDisplayName) {
170
-                    case 'desc':
171
-                        $this->_doorName = $attr->Value;
172
-                        break;
173
-                    case 'doorstate':
174
-                        $this->_doorState = $attr->Value;
175
-                        // UpdatedTime is a timestamp in ms, so we truncate
176
-                        $this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
177
-                        break;
178
-                    default:
179
-                        continue;
180
-                }
181
-            }
182
-        }
183
-    }
167
+			$this->_deviceId = $device->MyQDeviceId;
168
+			foreach ($device->Attributes as $attr) {
169
+				switch ($attr->AttributeDisplayName) {
170
+					case 'desc':
171
+						$this->_doorName = $attr->Value;
172
+						break;
173
+					case 'doorstate':
174
+						$this->_doorState = $attr->Value;
175
+						// UpdatedTime is a timestamp in ms, so we truncate
176
+						$this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
177
+						break;
178
+					default:
179
+						continue;
180
+				}
181
+			}
182
+		}
183
+	}
184 184
 }
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -167,16 +167,16 @@
 block discarded – undo
167 167
             $this->_deviceId = $device->MyQDeviceId;
168 168
             foreach ($device->Attributes as $attr) {
169 169
                 switch ($attr->AttributeDisplayName) {
170
-                    case 'desc':
171
-                        $this->_doorName = $attr->Value;
172
-                        break;
173
-                    case 'doorstate':
174
-                        $this->_doorState = $attr->Value;
175
-                        // UpdatedTime is a timestamp in ms, so we truncate
176
-                        $this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
177
-                        break;
178
-                    default:
179
-                        continue;
170
+                case 'desc':
171
+                    $this->_doorName = $attr->Value;
172
+                    break;
173
+                case 'doorstate':
174
+                    $this->_doorState = $attr->Value;
175
+                    // UpdatedTime is a timestamp in ms, so we truncate
176
+                    $this->_doorStateTime = (int)$attr->UpdatedTime / 1000;
177
+                    break;
178
+                default:
179
+                    continue;
180 180
                 }
181 181
             }
182 182
         }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @return MyQ
45 45
      */
46
-    public function __construct ($params = array()) {
46
+    public function __construct($params = array()) {
47 47
         // Overwrite class variables
48 48
         foreach ($params as $k => $v) {
49 49
             $this->$k = $v;
50 50
         }
51 51
         // Initialize cURL request headers
52
-        if (sizeof($this->_headers) == 0) {
53
-            $this->_headers = array (
52
+        if (sizeof($this->_headers)==0) {
53
+            $this->_headers = array(
54 54
                 'MyQApplicationId' => $this->appId,
55 55
                 'Culture' => $this->culture,
56 56
                 'Content-Type' => $this->contentType,
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @return MyQ
71 71
      */
72
-    public function login ($username = null, $password = null) {
72
+    public function login($username = null, $password = null) {
73 73
         // Set username/password if not null
74 74
         if (!is_null($username)) {
75 75
             $this->username = $username;
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
         if (is_null($this->password)) {
86 86
             $error[] = 'password';
87 87
         }
88
-        if (sizeof($error) > 0) {
89
-            throw new MyQException('Missing required auth credential: ' . implode(',', $error));
88
+        if (sizeof($error)>0) {
89
+            throw new MyQException('Missing required auth credential: '.implode(',', $error));
90 90
         }
91 91
         $this->_login();
92 92
     }
93
-    public function getState () {
93
+    public function getState() {
94 94
         $this->_getDetails();
95 95
         $timeInState = time() - $this->_doorStateTime;
96
-        echo implode(',', array (
96
+        echo implode(',', array(
97 97
             $this->_locationName,
98 98
             $this->_doorName,
99 99
             $this->_doorState,
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 		return $this->_getDetails();
106 106
 	}
107 107
 	
108
-    private function _init () {
108
+    private function _init() {
109 109
         if (!isset($this->_conn)) {
110 110
             $this->_conn = curl_init();
111
-            curl_setopt_array($this->_conn, array (
111
+            curl_setopt_array($this->_conn, array(
112 112
                 CURLOPT_RETURNTRANSFER => true,
113 113
                 CURLOPT_ENCODING => "",
114 114
                 CURLOPT_MAXREDIRS => 10,
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
         }
124 124
         $this->_setHeaders();
125 125
     }
126
-    private function _setHeaders () {
126
+    private function _setHeaders() {
127 127
         $headers = array();
128 128
         foreach ($this->_headers as $k => $v) {
129 129
             $headers[] = "$k: $v";
130 130
         }
131 131
         curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers);
132 132
     }
133
-    private function _login () {
133
+    private function _login() {
134 134
         $this->_init();
135 135
         curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST');
136 136
         curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl);
@@ -138,27 +138,27 @@  discard block
 block discarded – undo
138 138
         curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post);
139 139
         $output = curl_exec($this->_conn);
140 140
         $data = json_decode($output);
141
-        if ($data == false || !isset($data->SecurityToken)) {
141
+        if ($data==false || !isset($data->SecurityToken)) {
142 142
             throw new MyQException("Error processing login request: $output");
143 143
         }
144 144
         $this->_headers['SecurityToken'] = $data->SecurityToken;
145 145
         return $this;
146 146
     }
147
-    private function _getDetails () {
147
+    private function _getDetails() {
148 148
         $this->_init();
149 149
         curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET');
150 150
         curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl);
151 151
         $output = curl_exec($this->_conn);
152 152
         $data = json_decode($output);
153
-        if ($data == false || !isset($data->Devices)) {
153
+        if ($data==false || !isset($data->Devices)) {
154 154
             throw new MyQException("Error fetching device details: $output");
155 155
         }
156 156
         // Find our door device ID
157 157
         foreach ($data->Devices as $device) {
158
-            if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) {
158
+            if (stripos($device->MyQDeviceTypeName, "Gateway")!==false) {
159 159
                 // Find location name
160 160
                 foreach ($device->Attributes as $attr) {
161
-                    if ($attr->AttributeDisplayName == 'desc') {
161
+                    if ($attr->AttributeDisplayName=='desc') {
162 162
                         $this->_locationName = $attr->Value;
163 163
                     }
164 164
                 }
Please login to merge, or discard this patch.
examples/GarageDoorOpener/get_myq_devices.php 2 patches
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\Route;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 	namespace Route4Me;
3 3
 		
4
-	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
4
+	$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 	
6 6
 	require $vdir.'/../vendor/autoload.php';
7 7
 	//require __DIR__.'/../vendor/autoload.php';;
Please login to merge, or discard this patch.
examples/GarageDoorOpener/myq_login.php 2 patches
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\Route;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 	namespace Route4Me;
3 3
 		
4
-	$vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
4
+	$vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/';
5 5
 	
6 6
 	require $vdir.'/../vendor/autoload.php';
7 7
 	//require __DIR__.'/../vendor/autoload.php';;
Please login to merge, or discard this patch.