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 ( df19ab...5f95fa )
by Jared
03:05
created
src/JCFirebase.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@
 block discarded – undo
56 56
 		}
57 57
 	}
58 58
 
59
+	/**
60
+	 * @param string $firebaseServiceAccount
61
+	 */
59 62
 	public function setAuth( $firebaseServiceAccount ) {
60 63
 		if ( isset( $firebaseServiceAccount['key'] ) && isset( $firebaseServiceAccount['iss'] ) ) {
61 64
 			$this->auth = new OAuth( $firebaseServiceAccount['key'], $firebaseServiceAccount['iss'] );
Please login to merge, or discard this patch.
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -16,182 +16,182 @@
 block discarded – undo
16 16
  * reference https://www.firebase.com/docs/rest/api/
17 17
  */
18 18
 class JCFirebase {
19
-	public $firebaseURI;
20
-	public $firebaseDefaultPath;
21
-	public $requestHeader = array(
22
-		'accept'      => 'application/json',
23
-		'contentType' => 'application/json; charset=utf-8',
24
-		'dataType'    => 'json'
25
-	);
26
-	public $requestOptions = array();
27
-	/**
28
-	 * @var OAuth
29
-	 */
30
-	protected $auth;
31
-
32
-	public function __construct( $firebaseURI, $firebaseSerivceAccount = '', $firebaseDefaultPath = '/' ) {
33
-		$this->firebaseURI         = $firebaseURI;
34
-		$this->firebaseDefaultPath = $firebaseDefaultPath;
35
-		$this->setAuth( $firebaseSerivceAccount );
36
-	}
37
-
38
-	public static function fromKeyFile( $firebaseURI, $keyFile, $firebaseDefaultPath = '/' ) {
39
-		$keyData = null;
40
-		try {
41
-			$keyData = json_decode( file_get_contents( $keyFile ) );
42
-		} catch ( \Exception $exception ) {
43
-			$keyData = json_decode( Requests::get( $keyFile ) );
44
-		}
45
-
46
-		if ( $keyData ) {
47
-			$serviceAccount = $keyData->client_email;
48
-			$privateKey     = $keyData->private_key;
49
-
50
-			return new self( $firebaseURI, array(
51
-				'key' => $privateKey,
52
-				'iss' => $serviceAccount
53
-			), $firebaseDefaultPath );
54
-		} else {
55
-			throw new \Exception( "can't get data from key file" );
56
-		}
57
-	}
58
-
59
-	public function setAuth( $firebaseServiceAccount ) {
60
-		if ( isset( $firebaseServiceAccount['key'] ) && isset( $firebaseServiceAccount['iss'] ) ) {
61
-			$this->auth = new OAuth( $firebaseServiceAccount['key'], $firebaseServiceAccount['iss'] );
62
-		}
63
-	}
64
-
65
-	public function getPathURI( $path = '', $print = '' ) {
66
-		//remove last slash from firebaseURI
67
-		$template          = '/';
68
-		$this->firebaseURI = rtrim( $this->firebaseURI, $template );
69
-		$path              = rtrim( $path, $template );
70
-		$path              = ltrim( $path, $template );
71
-
72
-		//check https
73
-		if ( strpos( $this->firebaseURI, 'http://' ) !== false ) {
74
-			throw new \Exception( "https is required." );
75
-		}
76
-
77
-		//check firebaseURI
78
-		if ( empty( $this->firebaseURI ) ) {
79
-			throw new \Exception( "firebase URI is required" );
80
-		}
81
-
82
-		if ( strpos( $this->firebaseDefaultPath, "/" ) !== 0 ) {
83
-			throw new \Exception( "firebase default path must contain /" );
84
-		}
85
-
86
-		$pathURI = $this->firebaseURI . $this->firebaseDefaultPath . $path . ".json";
87
-
88
-		//set query data
89
-		$queryData = array();
90
-		if ( ! empty( $print ) ) {
91
-			$queryData[ JCFirebaseOption::OPTION_PRINT ] = $print;
92
-		}
93
-		if ( ! empty( $queryData ) ) {
94
-			$pathURI = $pathURI . '?' . http_build_query( $queryData );
95
-		}
96
-
97
-		$this->refreshToken();
98
-
99
-		return $pathURI;
100
-	}
101
-
102
-	public function getShallow( $path = '', $options = array() ) {
103
-		return Requests::get(
104
-			$this->getPathURI( $path ) . '?' . http_build_query( array(
105
-				JCFirebaseOption::OPTION_SHALLOW => JCFirebaseOption::SHALLOW_TRUE
106
-			) ),
107
-			$this->requestHeader,
108
-			$this->addDataToRequest( $options )
109
-		);
110
-	}
111
-
112
-	/**
113
-	 * @param string $path
114
-	 * @param array $options
115
-	 *
116
-	 * @return \Requests_Response
117
-	 */
118
-	public function get( $path = '', $options = array() ) {
119
-		return Requests::get(
120
-			$this->addDataToPathURI( $path, $options ), $this->requestHeader,
121
-			$this->addDataToRequest( $options )
122
-		);
123
-	}
124
-
125
-	/**
126
-	 * @param string $path
127
-	 * @param array $options
128
-	 *
129
-	 * @return \Requests_Response
130
-	 */
131
-	public function put( $path = '', $options = array() ) {
132
-		return Requests::put( $this->getPathURI( $path ), $this->requestHeader,
133
-			$this->addDataToRequest( $options, true ) );
134
-	}
135
-
136
-	/**
137
-	 * @param string $path
138
-	 * @param array $options
139
-	 *
140
-	 * @return \Requests_Response
141
-	 */
142
-	public function post( $path = '', $options = array() ) {
143
-		return Requests::post( $this->getPathURI( $path ), $this->requestHeader,
144
-			$this->addDataToRequest( $options, true ) );
145
-	}
146
-
147
-	/**
148
-	 * @param string $path
149
-	 * @param array $options
150
-	 *
151
-	 * @return \Requests_Response
152
-	 */
153
-	public function patch( $path = '', $options = array() ) {
154
-		return Requests::patch( $this->getPathURI( $path ), $this->requestHeader,
155
-			$this->addDataToRequest( $options, true ) );
156
-	}
157
-
158
-	/**
159
-	 * @param string $path
160
-	 * @param array $options
161
-	 *
162
-	 * @return \Requests_Response
163
-	 */
164
-	public function delete( $path = '', $options = array() ) {
165
-		return Requests::delete( $this->getPathURI( $path ), $this->requestHeader,
166
-			$this->addDataToRequest( $options ) );
167
-	}
168
-
169
-	protected function refreshToken() {
170
-		$this->requestHeader['Authorization'] = 'Bearer ' . $this->auth->getAccessToken();
171
-	}
172
-
173
-	protected function addDataToPathURI( $path = '', $options = array(), $reqType = JCFirebaseOption::REQ_TYPE_GET ) {
174
-		$print = '';
175
-		if ( isset( $options['print'] ) ) {
176
-			if ( JCFirebaseOption::isAllowPrint( $reqType, $options['print'] ) ) {
177
-				$print = $options['print'];
178
-			}
179
-		}
180
-
181
-		return $this->getPathURI( $path, $print );
182
-	}
183
-
184
-	protected function addDataToRequest( $options = array(), $jsonEncode = false ) {
185
-		$requestOptions = array();
186
-
187
-		if ( isset( $options['data'] ) ) {
188
-			$requestOptions = array_merge( $options['data'], $requestOptions );
189
-		}
190
-
191
-		if ( $jsonEncode ) {
192
-			$requestOptions = json_encode( $requestOptions );
193
-		}
194
-
195
-		return $requestOptions;
196
-	}
19
+    public $firebaseURI;
20
+    public $firebaseDefaultPath;
21
+    public $requestHeader = array(
22
+        'accept'      => 'application/json',
23
+        'contentType' => 'application/json; charset=utf-8',
24
+        'dataType'    => 'json'
25
+    );
26
+    public $requestOptions = array();
27
+    /**
28
+     * @var OAuth
29
+     */
30
+    protected $auth;
31
+
32
+    public function __construct( $firebaseURI, $firebaseSerivceAccount = '', $firebaseDefaultPath = '/' ) {
33
+        $this->firebaseURI         = $firebaseURI;
34
+        $this->firebaseDefaultPath = $firebaseDefaultPath;
35
+        $this->setAuth( $firebaseSerivceAccount );
36
+    }
37
+
38
+    public static function fromKeyFile( $firebaseURI, $keyFile, $firebaseDefaultPath = '/' ) {
39
+        $keyData = null;
40
+        try {
41
+            $keyData = json_decode( file_get_contents( $keyFile ) );
42
+        } catch ( \Exception $exception ) {
43
+            $keyData = json_decode( Requests::get( $keyFile ) );
44
+        }
45
+
46
+        if ( $keyData ) {
47
+            $serviceAccount = $keyData->client_email;
48
+            $privateKey     = $keyData->private_key;
49
+
50
+            return new self( $firebaseURI, array(
51
+                'key' => $privateKey,
52
+                'iss' => $serviceAccount
53
+            ), $firebaseDefaultPath );
54
+        } else {
55
+            throw new \Exception( "can't get data from key file" );
56
+        }
57
+    }
58
+
59
+    public function setAuth( $firebaseServiceAccount ) {
60
+        if ( isset( $firebaseServiceAccount['key'] ) && isset( $firebaseServiceAccount['iss'] ) ) {
61
+            $this->auth = new OAuth( $firebaseServiceAccount['key'], $firebaseServiceAccount['iss'] );
62
+        }
63
+    }
64
+
65
+    public function getPathURI( $path = '', $print = '' ) {
66
+        //remove last slash from firebaseURI
67
+        $template          = '/';
68
+        $this->firebaseURI = rtrim( $this->firebaseURI, $template );
69
+        $path              = rtrim( $path, $template );
70
+        $path              = ltrim( $path, $template );
71
+
72
+        //check https
73
+        if ( strpos( $this->firebaseURI, 'http://' ) !== false ) {
74
+            throw new \Exception( "https is required." );
75
+        }
76
+
77
+        //check firebaseURI
78
+        if ( empty( $this->firebaseURI ) ) {
79
+            throw new \Exception( "firebase URI is required" );
80
+        }
81
+
82
+        if ( strpos( $this->firebaseDefaultPath, "/" ) !== 0 ) {
83
+            throw new \Exception( "firebase default path must contain /" );
84
+        }
85
+
86
+        $pathURI = $this->firebaseURI . $this->firebaseDefaultPath . $path . ".json";
87
+
88
+        //set query data
89
+        $queryData = array();
90
+        if ( ! empty( $print ) ) {
91
+            $queryData[ JCFirebaseOption::OPTION_PRINT ] = $print;
92
+        }
93
+        if ( ! empty( $queryData ) ) {
94
+            $pathURI = $pathURI . '?' . http_build_query( $queryData );
95
+        }
96
+
97
+        $this->refreshToken();
98
+
99
+        return $pathURI;
100
+    }
101
+
102
+    public function getShallow( $path = '', $options = array() ) {
103
+        return Requests::get(
104
+            $this->getPathURI( $path ) . '?' . http_build_query( array(
105
+                JCFirebaseOption::OPTION_SHALLOW => JCFirebaseOption::SHALLOW_TRUE
106
+            ) ),
107
+            $this->requestHeader,
108
+            $this->addDataToRequest( $options )
109
+        );
110
+    }
111
+
112
+    /**
113
+     * @param string $path
114
+     * @param array $options
115
+     *
116
+     * @return \Requests_Response
117
+     */
118
+    public function get( $path = '', $options = array() ) {
119
+        return Requests::get(
120
+            $this->addDataToPathURI( $path, $options ), $this->requestHeader,
121
+            $this->addDataToRequest( $options )
122
+        );
123
+    }
124
+
125
+    /**
126
+     * @param string $path
127
+     * @param array $options
128
+     *
129
+     * @return \Requests_Response
130
+     */
131
+    public function put( $path = '', $options = array() ) {
132
+        return Requests::put( $this->getPathURI( $path ), $this->requestHeader,
133
+            $this->addDataToRequest( $options, true ) );
134
+    }
135
+
136
+    /**
137
+     * @param string $path
138
+     * @param array $options
139
+     *
140
+     * @return \Requests_Response
141
+     */
142
+    public function post( $path = '', $options = array() ) {
143
+        return Requests::post( $this->getPathURI( $path ), $this->requestHeader,
144
+            $this->addDataToRequest( $options, true ) );
145
+    }
146
+
147
+    /**
148
+     * @param string $path
149
+     * @param array $options
150
+     *
151
+     * @return \Requests_Response
152
+     */
153
+    public function patch( $path = '', $options = array() ) {
154
+        return Requests::patch( $this->getPathURI( $path ), $this->requestHeader,
155
+            $this->addDataToRequest( $options, true ) );
156
+    }
157
+
158
+    /**
159
+     * @param string $path
160
+     * @param array $options
161
+     *
162
+     * @return \Requests_Response
163
+     */
164
+    public function delete( $path = '', $options = array() ) {
165
+        return Requests::delete( $this->getPathURI( $path ), $this->requestHeader,
166
+            $this->addDataToRequest( $options ) );
167
+    }
168
+
169
+    protected function refreshToken() {
170
+        $this->requestHeader['Authorization'] = 'Bearer ' . $this->auth->getAccessToken();
171
+    }
172
+
173
+    protected function addDataToPathURI( $path = '', $options = array(), $reqType = JCFirebaseOption::REQ_TYPE_GET ) {
174
+        $print = '';
175
+        if ( isset( $options['print'] ) ) {
176
+            if ( JCFirebaseOption::isAllowPrint( $reqType, $options['print'] ) ) {
177
+                $print = $options['print'];
178
+            }
179
+        }
180
+
181
+        return $this->getPathURI( $path, $print );
182
+    }
183
+
184
+    protected function addDataToRequest( $options = array(), $jsonEncode = false ) {
185
+        $requestOptions = array();
186
+
187
+        if ( isset( $options['data'] ) ) {
188
+            $requestOptions = array_merge( $options['data'], $requestOptions );
189
+        }
190
+
191
+        if ( $jsonEncode ) {
192
+            $requestOptions = json_encode( $requestOptions );
193
+        }
194
+
195
+        return $requestOptions;
196
+    }
197 197
 }
198 198
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -29,69 +29,69 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	protected $auth;
31 31
 
32
-	public function __construct( $firebaseURI, $firebaseSerivceAccount = '', $firebaseDefaultPath = '/' ) {
32
+	public function __construct($firebaseURI, $firebaseSerivceAccount = '', $firebaseDefaultPath = '/') {
33 33
 		$this->firebaseURI         = $firebaseURI;
34 34
 		$this->firebaseDefaultPath = $firebaseDefaultPath;
35
-		$this->setAuth( $firebaseSerivceAccount );
35
+		$this->setAuth($firebaseSerivceAccount);
36 36
 	}
37 37
 
38
-	public static function fromKeyFile( $firebaseURI, $keyFile, $firebaseDefaultPath = '/' ) {
38
+	public static function fromKeyFile($firebaseURI, $keyFile, $firebaseDefaultPath = '/') {
39 39
 		$keyData = null;
40 40
 		try {
41
-			$keyData = json_decode( file_get_contents( $keyFile ) );
42
-		} catch ( \Exception $exception ) {
43
-			$keyData = json_decode( Requests::get( $keyFile ) );
41
+			$keyData = json_decode(file_get_contents($keyFile));
42
+		} catch (\Exception $exception) {
43
+			$keyData = json_decode(Requests::get($keyFile));
44 44
 		}
45 45
 
46
-		if ( $keyData ) {
46
+		if ($keyData) {
47 47
 			$serviceAccount = $keyData->client_email;
48 48
 			$privateKey     = $keyData->private_key;
49 49
 
50
-			return new self( $firebaseURI, array(
50
+			return new self($firebaseURI, array(
51 51
 				'key' => $privateKey,
52 52
 				'iss' => $serviceAccount
53
-			), $firebaseDefaultPath );
53
+			), $firebaseDefaultPath);
54 54
 		} else {
55
-			throw new \Exception( "can't get data from key file" );
55
+			throw new \Exception("can't get data from key file");
56 56
 		}
57 57
 	}
58 58
 
59
-	public function setAuth( $firebaseServiceAccount ) {
60
-		if ( isset( $firebaseServiceAccount['key'] ) && isset( $firebaseServiceAccount['iss'] ) ) {
61
-			$this->auth = new OAuth( $firebaseServiceAccount['key'], $firebaseServiceAccount['iss'] );
59
+	public function setAuth($firebaseServiceAccount) {
60
+		if (isset($firebaseServiceAccount['key']) && isset($firebaseServiceAccount['iss'])) {
61
+			$this->auth = new OAuth($firebaseServiceAccount['key'], $firebaseServiceAccount['iss']);
62 62
 		}
63 63
 	}
64 64
 
65
-	public function getPathURI( $path = '', $print = '' ) {
65
+	public function getPathURI($path = '', $print = '') {
66 66
 		//remove last slash from firebaseURI
67 67
 		$template          = '/';
68
-		$this->firebaseURI = rtrim( $this->firebaseURI, $template );
69
-		$path              = rtrim( $path, $template );
70
-		$path              = ltrim( $path, $template );
68
+		$this->firebaseURI = rtrim($this->firebaseURI, $template);
69
+		$path              = rtrim($path, $template);
70
+		$path              = ltrim($path, $template);
71 71
 
72 72
 		//check https
73
-		if ( strpos( $this->firebaseURI, 'http://' ) !== false ) {
74
-			throw new \Exception( "https is required." );
73
+		if (strpos($this->firebaseURI, 'http://') !== false) {
74
+			throw new \Exception("https is required.");
75 75
 		}
76 76
 
77 77
 		//check firebaseURI
78
-		if ( empty( $this->firebaseURI ) ) {
79
-			throw new \Exception( "firebase URI is required" );
78
+		if (empty($this->firebaseURI)) {
79
+			throw new \Exception("firebase URI is required");
80 80
 		}
81 81
 
82
-		if ( strpos( $this->firebaseDefaultPath, "/" ) !== 0 ) {
83
-			throw new \Exception( "firebase default path must contain /" );
82
+		if (strpos($this->firebaseDefaultPath, "/") !== 0) {
83
+			throw new \Exception("firebase default path must contain /");
84 84
 		}
85 85
 
86
-		$pathURI = $this->firebaseURI . $this->firebaseDefaultPath . $path . ".json";
86
+		$pathURI = $this->firebaseURI.$this->firebaseDefaultPath.$path.".json";
87 87
 
88 88
 		//set query data
89 89
 		$queryData = array();
90
-		if ( ! empty( $print ) ) {
91
-			$queryData[ JCFirebaseOption::OPTION_PRINT ] = $print;
90
+		if (!empty($print)) {
91
+			$queryData[JCFirebaseOption::OPTION_PRINT] = $print;
92 92
 		}
93
-		if ( ! empty( $queryData ) ) {
94
-			$pathURI = $pathURI . '?' . http_build_query( $queryData );
93
+		if (!empty($queryData)) {
94
+			$pathURI = $pathURI.'?'.http_build_query($queryData);
95 95
 		}
96 96
 
97 97
 		$this->refreshToken();
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 		return $pathURI;
100 100
 	}
101 101
 
102
-	public function getShallow( $path = '', $options = array() ) {
102
+	public function getShallow($path = '', $options = array()) {
103 103
 		return Requests::get(
104
-			$this->getPathURI( $path ) . '?' . http_build_query( array(
104
+			$this->getPathURI($path).'?'.http_build_query(array(
105 105
 				JCFirebaseOption::OPTION_SHALLOW => JCFirebaseOption::SHALLOW_TRUE
106
-			) ),
106
+			)),
107 107
 			$this->requestHeader,
108
-			$this->addDataToRequest( $options )
108
+			$this->addDataToRequest($options)
109 109
 		);
110 110
 	}
111 111
 
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return \Requests_Response
117 117
 	 */
118
-	public function get( $path = '', $options = array() ) {
118
+	public function get($path = '', $options = array()) {
119 119
 		return Requests::get(
120
-			$this->addDataToPathURI( $path, $options ), $this->requestHeader,
121
-			$this->addDataToRequest( $options )
120
+			$this->addDataToPathURI($path, $options), $this->requestHeader,
121
+			$this->addDataToRequest($options)
122 122
 		);
123 123
 	}
124 124
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return \Requests_Response
130 130
 	 */
131
-	public function put( $path = '', $options = array() ) {
132
-		return Requests::put( $this->getPathURI( $path ), $this->requestHeader,
133
-			$this->addDataToRequest( $options, true ) );
131
+	public function put($path = '', $options = array()) {
132
+		return Requests::put($this->getPathURI($path), $this->requestHeader,
133
+			$this->addDataToRequest($options, true));
134 134
 	}
135 135
 
136 136
 	/**
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @return \Requests_Response
141 141
 	 */
142
-	public function post( $path = '', $options = array() ) {
143
-		return Requests::post( $this->getPathURI( $path ), $this->requestHeader,
144
-			$this->addDataToRequest( $options, true ) );
142
+	public function post($path = '', $options = array()) {
143
+		return Requests::post($this->getPathURI($path), $this->requestHeader,
144
+			$this->addDataToRequest($options, true));
145 145
 	}
146 146
 
147 147
 	/**
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return \Requests_Response
152 152
 	 */
153
-	public function patch( $path = '', $options = array() ) {
154
-		return Requests::patch( $this->getPathURI( $path ), $this->requestHeader,
155
-			$this->addDataToRequest( $options, true ) );
153
+	public function patch($path = '', $options = array()) {
154
+		return Requests::patch($this->getPathURI($path), $this->requestHeader,
155
+			$this->addDataToRequest($options, true));
156 156
 	}
157 157
 
158 158
 	/**
@@ -161,35 +161,35 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return \Requests_Response
163 163
 	 */
164
-	public function delete( $path = '', $options = array() ) {
165
-		return Requests::delete( $this->getPathURI( $path ), $this->requestHeader,
166
-			$this->addDataToRequest( $options ) );
164
+	public function delete($path = '', $options = array()) {
165
+		return Requests::delete($this->getPathURI($path), $this->requestHeader,
166
+			$this->addDataToRequest($options));
167 167
 	}
168 168
 
169 169
 	protected function refreshToken() {
170
-		$this->requestHeader['Authorization'] = 'Bearer ' . $this->auth->getAccessToken();
170
+		$this->requestHeader['Authorization'] = 'Bearer '.$this->auth->getAccessToken();
171 171
 	}
172 172
 
173
-	protected function addDataToPathURI( $path = '', $options = array(), $reqType = JCFirebaseOption::REQ_TYPE_GET ) {
173
+	protected function addDataToPathURI($path = '', $options = array(), $reqType = JCFirebaseOption::REQ_TYPE_GET) {
174 174
 		$print = '';
175
-		if ( isset( $options['print'] ) ) {
176
-			if ( JCFirebaseOption::isAllowPrint( $reqType, $options['print'] ) ) {
175
+		if (isset($options['print'])) {
176
+			if (JCFirebaseOption::isAllowPrint($reqType, $options['print'])) {
177 177
 				$print = $options['print'];
178 178
 			}
179 179
 		}
180 180
 
181
-		return $this->getPathURI( $path, $print );
181
+		return $this->getPathURI($path, $print);
182 182
 	}
183 183
 
184
-	protected function addDataToRequest( $options = array(), $jsonEncode = false ) {
184
+	protected function addDataToRequest($options = array(), $jsonEncode = false) {
185 185
 		$requestOptions = array();
186 186
 
187
-		if ( isset( $options['data'] ) ) {
188
-			$requestOptions = array_merge( $options['data'], $requestOptions );
187
+		if (isset($options['data'])) {
188
+			$requestOptions = array_merge($options['data'], $requestOptions);
189 189
 		}
190 190
 
191
-		if ( $jsonEncode ) {
192
-			$requestOptions = json_encode( $requestOptions );
191
+		if ($jsonEncode) {
192
+			$requestOptions = json_encode($requestOptions);
193 193
 		}
194 194
 
195 195
 		return $requestOptions;
Please login to merge, or discard this patch.
src/OAuth.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -12,63 +12,63 @@
 block discarded – undo
12 12
 use Requests;
13 13
 
14 14
 class OAuth {
15
-	/*
15
+    /*
16 16
 	 * token life time in second
17 17
 	 * */
18
-	public $tokenLifeTime;
19
-	public $key;
20
-	public $iss;
18
+    public $tokenLifeTime;
19
+    public $key;
20
+    public $iss;
21 21
 
22
-	protected $expireTimestamp;
23
-	protected $accessToken;
22
+    protected $expireTimestamp;
23
+    protected $accessToken;
24 24
 
25
-	/**
26
-	 * OAuth constructor.
27
-	 *
28
-	 * @param $key
29
-	 * @param $iss
30
-	 */
31
-	public function __construct( $key, $iss, $tokenLifeTime = 3600 ) {
32
-		$this->key           = $key;
33
-		$this->iss           = $iss;
34
-		$this->tokenLifeTime = $tokenLifeTime;
35
-	}
25
+    /**
26
+     * OAuth constructor.
27
+     *
28
+     * @param $key
29
+     * @param $iss
30
+     */
31
+    public function __construct( $key, $iss, $tokenLifeTime = 3600 ) {
32
+        $this->key           = $key;
33
+        $this->iss           = $iss;
34
+        $this->tokenLifeTime = $tokenLifeTime;
35
+    }
36 36
 
37
-	protected function requestAccessToken() {
38
-		$currentTimestamp      = time();
39
-		$this->expireTimestamp = $currentTimestamp + $this->tokenLifeTime;
40
-		$jsonToken             = array(
41
-			"iss"   => $this->iss,
42
-			"scope" => "https://www.googleapis.com/auth/firebase.database https://www.googleapis.com/auth/userinfo.email",
43
-			"aud"   => "https://www.googleapis.com/oauth2/v4/token",
44
-			"exp"   => $this->expireTimestamp,
45
-			"iat"   => $currentTimestamp
46
-		);
47
-		$jwt                   = JWT::encode( $jsonToken, $this->key, 'RS256' );
37
+    protected function requestAccessToken() {
38
+        $currentTimestamp      = time();
39
+        $this->expireTimestamp = $currentTimestamp + $this->tokenLifeTime;
40
+        $jsonToken             = array(
41
+            "iss"   => $this->iss,
42
+            "scope" => "https://www.googleapis.com/auth/firebase.database https://www.googleapis.com/auth/userinfo.email",
43
+            "aud"   => "https://www.googleapis.com/oauth2/v4/token",
44
+            "exp"   => $this->expireTimestamp,
45
+            "iat"   => $currentTimestamp
46
+        );
47
+        $jwt                   = JWT::encode( $jsonToken, $this->key, 'RS256' );
48 48
 
49
-		$OAuthResponse = Requests::post( 'https://www.googleapis.com/oauth2/v4/token', array(), array(
50
-			'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
51
-			'assertion'  => $jwt
52
-		) );
49
+        $OAuthResponse = Requests::post( 'https://www.googleapis.com/oauth2/v4/token', array(), array(
50
+            'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
51
+            'assertion'  => $jwt
52
+        ) );
53 53
 
54
-		if ( $OAuthResponse->status_code == 200 ) {
55
-			$this->accessToken = json_decode( $OAuthResponse->body )->access_token;
54
+        if ( $OAuthResponse->status_code == 200 ) {
55
+            $this->accessToken = json_decode( $OAuthResponse->body )->access_token;
56 56
 
57
-			return true;
58
-		}
57
+            return true;
58
+        }
59 59
 
60
-		return false;
61
-	}
60
+        return false;
61
+    }
62 62
 
63
-	public function getAccessToken() {
64
-		$currentTime = time();
65
-		if ( $this->expireTimestamp < $currentTime ) {
66
-			$startTime = time();
67
-			$this->requestAccessToken();
68
-			$endTime = time();
69
-			$this->expireTimestamp -= ( $endTime - $startTime );
70
-		}
63
+    public function getAccessToken() {
64
+        $currentTime = time();
65
+        if ( $this->expireTimestamp < $currentTime ) {
66
+            $startTime = time();
67
+            $this->requestAccessToken();
68
+            $endTime = time();
69
+            $this->expireTimestamp -= ( $endTime - $startTime );
70
+        }
71 71
 
72
-		return $this->accessToken;
73
-	}
72
+        return $this->accessToken;
73
+    }
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param $key
29 29
 	 * @param $iss
30 30
 	 */
31
-	public function __construct( $key, $iss, $tokenLifeTime = 3600 ) {
31
+	public function __construct($key, $iss, $tokenLifeTime = 3600) {
32 32
 		$this->key           = $key;
33 33
 		$this->iss           = $iss;
34 34
 		$this->tokenLifeTime = $tokenLifeTime;
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
 			"exp"   => $this->expireTimestamp,
45 45
 			"iat"   => $currentTimestamp
46 46
 		);
47
-		$jwt                   = JWT::encode( $jsonToken, $this->key, 'RS256' );
47
+		$jwt = JWT::encode($jsonToken, $this->key, 'RS256');
48 48
 
49
-		$OAuthResponse = Requests::post( 'https://www.googleapis.com/oauth2/v4/token', array(), array(
49
+		$OAuthResponse = Requests::post('https://www.googleapis.com/oauth2/v4/token', array(), array(
50 50
 			'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
51 51
 			'assertion'  => $jwt
52
-		) );
52
+		));
53 53
 
54
-		if ( $OAuthResponse->status_code == 200 ) {
55
-			$this->accessToken = json_decode( $OAuthResponse->body )->access_token;
54
+		if ($OAuthResponse->status_code == 200) {
55
+			$this->accessToken = json_decode($OAuthResponse->body)->access_token;
56 56
 
57 57
 			return true;
58 58
 		}
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 
63 63
 	public function getAccessToken() {
64 64
 		$currentTime = time();
65
-		if ( $this->expireTimestamp < $currentTime ) {
65
+		if ($this->expireTimestamp < $currentTime) {
66 66
 			$startTime = time();
67 67
 			$this->requestAccessToken();
68 68
 			$endTime = time();
69
-			$this->expireTimestamp -= ( $endTime - $startTime );
69
+			$this->expireTimestamp -= ($endTime - $startTime);
70 70
 		}
71 71
 
72 72
 		return $this->accessToken;
Please login to merge, or discard this patch.
src/JCFirebaseOption.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -10,33 +10,33 @@
 block discarded – undo
10 10
 
11 11
 
12 12
 class JCFirebaseOption {
13
-	const __default = null;
14
-
15
-	const OPTION_SHALLOW = 'shallow';
16
-	const SHALLOW_TRUE = 'true';
17
-	const SHALLOW_FALSE = 'false';
18
-
19
-	const OPTION_PRINT = 'print';
20
-	const PRINT_PRETTY = 'pretty';
21
-	const PRINT_SILENT = 'silent';
22
-
23
-	const REQ_TYPE_GET = 0;
24
-	const REQ_TYPE_PUT = 1;
25
-	const REQ_TYPE_POST = 2;
26
-	const REQ_TYPE_PATCH = 3;
27
-	const REQ_TYPE_DELETE = 4;
28
-
29
-	public static function isAllowPrint( $reqType = self::REQ_TYPE_GET, $pType = self::PRINT_PRETTY ) {
30
-		if ( $pType == self::PRINT_PRETTY ) {
31
-			return true;
32
-		}
33
-
34
-		if ( $pType == self::PRINT_SILENT ) {
35
-			if ( $reqType == self::REQ_TYPE_DELETE ) {
36
-				return false;
37
-			}
38
-		}
39
-
40
-		return true;
41
-	}
13
+    const __default = null;
14
+
15
+    const OPTION_SHALLOW = 'shallow';
16
+    const SHALLOW_TRUE = 'true';
17
+    const SHALLOW_FALSE = 'false';
18
+
19
+    const OPTION_PRINT = 'print';
20
+    const PRINT_PRETTY = 'pretty';
21
+    const PRINT_SILENT = 'silent';
22
+
23
+    const REQ_TYPE_GET = 0;
24
+    const REQ_TYPE_PUT = 1;
25
+    const REQ_TYPE_POST = 2;
26
+    const REQ_TYPE_PATCH = 3;
27
+    const REQ_TYPE_DELETE = 4;
28
+
29
+    public static function isAllowPrint( $reqType = self::REQ_TYPE_GET, $pType = self::PRINT_PRETTY ) {
30
+        if ( $pType == self::PRINT_PRETTY ) {
31
+            return true;
32
+        }
33
+
34
+        if ( $pType == self::PRINT_SILENT ) {
35
+            if ( $reqType == self::REQ_TYPE_DELETE ) {
36
+                return false;
37
+            }
38
+        }
39
+
40
+        return true;
41
+    }
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 	const REQ_TYPE_PATCH = 3;
27 27
 	const REQ_TYPE_DELETE = 4;
28 28
 
29
-	public static function isAllowPrint( $reqType = self::REQ_TYPE_GET, $pType = self::PRINT_PRETTY ) {
30
-		if ( $pType == self::PRINT_PRETTY ) {
29
+	public static function isAllowPrint($reqType = self::REQ_TYPE_GET, $pType = self::PRINT_PRETTY) {
30
+		if ($pType == self::PRINT_PRETTY) {
31 31
 			return true;
32 32
 		}
33 33
 
34
-		if ( $pType == self::PRINT_SILENT ) {
35
-			if ( $reqType == self::REQ_TYPE_DELETE ) {
34
+		if ($pType == self::PRINT_SILENT) {
35
+			if ($reqType == self::REQ_TYPE_DELETE) {
36 36
 				return false;
37 37
 			}
38 38
 		}
Please login to merge, or discard this patch.