Test Setup Failed
Pull Request — master (#454)
by Kiran
29:40
created
geodirectory-admin/google-api-php-client/src/Google/Service/Exception.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
    * @param array|null $retryMap Map of errors with retry counts.
44 44
    */
45 45
   public function __construct(
46
-      $message,
47
-      $code = 0,
48
-      Exception $previous = null,
49
-      $errors = array(),
50
-      array $retryMap = null
46
+	  $message,
47
+	  $code = 0,
48
+	  Exception $previous = null,
49
+	  $errors = array(),
50
+	  array $retryMap = null
51 51
   ) {
52
-    if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
53
-      parent::__construct($message, $code, $previous);
54
-    } else {
55
-      parent::__construct($message, $code);
56
-    }
52
+	if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
53
+	  parent::__construct($message, $code, $previous);
54
+	} else {
55
+	  parent::__construct($message, $code);
56
+	}
57 57
 
58
-    $this->errors = $errors;
58
+	$this->errors = $errors;
59 59
 
60
-    if (is_array($retryMap)) {
61
-      $this->retryMap = $retryMap;
62
-    }
60
+	if (is_array($retryMap)) {
61
+	  $this->retryMap = $retryMap;
62
+	}
63 63
   }
64 64
 
65 65
   /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
    */
78 78
   public function getErrors()
79 79
   {
80
-    return $this->errors;
80
+	return $this->errors;
81 81
   }
82 82
 
83 83
   /**
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
    */
90 90
   public function allowedRetries()
91 91
   {
92
-    if (isset($this->retryMap[$this->code])) {
93
-      return $this->retryMap[$this->code];
94
-    }
92
+	if (isset($this->retryMap[$this->code])) {
93
+	  return $this->retryMap[$this->code];
94
+	}
95 95
 
96
-    $errors = $this->getErrors();
96
+	$errors = $this->getErrors();
97 97
 
98
-    if (!empty($errors) && isset($errors[0]['reason']) &&
99
-        isset($this->retryMap[$errors[0]['reason']])) {
100
-      return $this->retryMap[$errors[0]['reason']];
101
-    }
98
+	if (!empty($errors) && isset($errors[0]['reason']) &&
99
+		isset($this->retryMap[$errors[0]['reason']])) {
100
+	  return $this->retryMap[$errors[0]['reason']];
101
+	}
102 102
 
103
-    return 0;
103
+	return 0;
104 104
   }
105 105
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 class Google_Service_Exception extends Google_Exception implements Google_Task_Retryable
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Signer/P12.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -34,61 +34,61 @@
 block discarded – undo
34 34
   // Creates a new signer from a .p12 file.
35 35
   public function __construct($p12, $password)
36 36
   {
37
-    if (!function_exists('openssl_x509_read')) {
38
-      throw new Google_Exception(
39
-          'The Google PHP API library needs the openssl PHP extension'
40
-      );
41
-    }
37
+	if (!function_exists('openssl_x509_read')) {
38
+	  throw new Google_Exception(
39
+		  'The Google PHP API library needs the openssl PHP extension'
40
+	  );
41
+	}
42 42
 
43
-    // If the private key is provided directly, then this isn't in the p12
44
-    // format. Different versions of openssl support different p12 formats
45
-    // and the key from google wasn't being accepted by the version available
46
-    // at the time.
47
-    if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) {
48
-      $this->privateKey = openssl_pkey_get_private($p12);
49
-    } elseif ($password === 'notasecret' && strpos($p12, "-----BEGIN PRIVATE KEY-----") !== false) {
50
-      $this->privateKey = openssl_pkey_get_private($p12);
51
-    } else {
52
-      // This throws on error
53
-      $certs = array();
54
-      if (!openssl_pkcs12_read($p12, $certs, $password)) {
55
-        throw new Google_Auth_Exception(
56
-            "Unable to parse the p12 file.  " .
57
-            "Is this a .p12 file?  Is the password correct?  OpenSSL error: " .
58
-            openssl_error_string()
59
-        );
60
-      }
61
-      // TODO(beaton): is this part of the contract for the openssl_pkcs12_read
62
-      // method?  What happens if there are multiple private keys?  Do we care?
63
-      if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) {
64
-        throw new Google_Auth_Exception("No private key found in p12 file.");
65
-      }
66
-      $this->privateKey = openssl_pkey_get_private($certs['pkey']);
67
-    }
43
+	// If the private key is provided directly, then this isn't in the p12
44
+	// format. Different versions of openssl support different p12 formats
45
+	// and the key from google wasn't being accepted by the version available
46
+	// at the time.
47
+	if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) {
48
+	  $this->privateKey = openssl_pkey_get_private($p12);
49
+	} elseif ($password === 'notasecret' && strpos($p12, "-----BEGIN PRIVATE KEY-----") !== false) {
50
+	  $this->privateKey = openssl_pkey_get_private($p12);
51
+	} else {
52
+	  // This throws on error
53
+	  $certs = array();
54
+	  if (!openssl_pkcs12_read($p12, $certs, $password)) {
55
+		throw new Google_Auth_Exception(
56
+			"Unable to parse the p12 file.  " .
57
+			"Is this a .p12 file?  Is the password correct?  OpenSSL error: " .
58
+			openssl_error_string()
59
+		);
60
+	  }
61
+	  // TODO(beaton): is this part of the contract for the openssl_pkcs12_read
62
+	  // method?  What happens if there are multiple private keys?  Do we care?
63
+	  if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) {
64
+		throw new Google_Auth_Exception("No private key found in p12 file.");
65
+	  }
66
+	  $this->privateKey = openssl_pkey_get_private($certs['pkey']);
67
+	}
68 68
 
69
-    if (!$this->privateKey) {
70
-      throw new Google_Auth_Exception("Unable to load private key");
71
-    }
69
+	if (!$this->privateKey) {
70
+	  throw new Google_Auth_Exception("Unable to load private key");
71
+	}
72 72
   }
73 73
 
74 74
   public function __destruct()
75 75
   {
76
-    if ($this->privateKey) {
77
-      openssl_pkey_free($this->privateKey);
78
-    }
76
+	if ($this->privateKey) {
77
+	  openssl_pkey_free($this->privateKey);
78
+	}
79 79
   }
80 80
 
81 81
   public function sign($data)
82 82
   {
83
-    if (version_compare(PHP_VERSION, '5.3.0') < 0) {
84
-      throw new Google_Auth_Exception(
85
-          "PHP 5.3.0 or higher is required to use service accounts."
86
-      );
87
-    }
88
-    $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
89
-    if (!openssl_sign($data, $signature, $this->privateKey, $hash)) {
90
-      throw new Google_Auth_Exception("Unable to sign data");
91
-    }
92
-    return $signature;
83
+	if (version_compare(PHP_VERSION, '5.3.0') < 0) {
84
+	  throw new Google_Auth_Exception(
85
+		  "PHP 5.3.0 or higher is required to use service accounts."
86
+	  );
87
+	}
88
+	$hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
89
+	if (!openssl_sign($data, $signature, $this->privateKey, $hash)) {
90
+	  throw new Google_Auth_Exception("Unable to sign data");
91
+	}
92
+	return $signature;
93 93
   }
94 94
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
       $certs = array();
54 54
       if (!openssl_pkcs12_read($p12, $certs, $password)) {
55 55
         throw new Google_Auth_Exception(
56
-            "Unable to parse the p12 file.  " .
57
-            "Is this a .p12 file?  Is the password correct?  OpenSSL error: " .
56
+            "Unable to parse the p12 file.  ".
57
+            "Is this a .p12 file?  Is the password correct?  OpenSSL error: ".
58 58
             openssl_error_string()
59 59
         );
60 60
       }
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Utils/URITemplate.php 2 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
    * processed.
33 33
    */
34 34
   private $operators = array(
35
-      "+" => "reserved",
36
-      "/" => "segments",
37
-      "." => "dotprefix",
38
-      "#" => "fragment",
39
-      ";" => "semicolon",
40
-      "?" => "form",
41
-      "&" => "continuation"
35
+	  "+" => "reserved",
36
+	  "/" => "segments",
37
+	  "." => "dotprefix",
38
+	  "#" => "fragment",
39
+	  ";" => "semicolon",
40
+	  "?" => "form",
41
+	  "&" => "continuation"
42 42
   );
43 43
 
44 44
   /**
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
    * strings.
48 48
    */
49 49
   private $reserved = array(
50
-      "=", ",", "!", "@", "|", ":", "/", "?", "#",
51
-      "[", "]",'$', "&", "'", "(", ")", "*", "+", ";"
50
+	  "=", ",", "!", "@", "|", ":", "/", "?", "#",
51
+	  "[", "]",'$', "&", "'", "(", ")", "*", "+", ";"
52 52
   );
53 53
   private $reservedEncoded = array(
54
-    "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
55
-    "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29",
56
-    "%2A", "%2B", "%3B"
54
+	"%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
55
+	"%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29",
56
+	"%2A", "%2B", "%3B"
57 57
   );
58 58
 
59 59
   public function parse($string, array $parameters)
60 60
   {
61
-    return $this->resolveNextSection($string, $parameters);
61
+	return $this->resolveNextSection($string, $parameters);
62 62
   }
63 63
 
64 64
   /**
@@ -68,208 +68,208 @@  discard block
 block discarded – undo
68 68
    */
69 69
   private function resolveNextSection($string, $parameters)
70 70
   {
71
-    $start = strpos($string, "{");
72
-    if ($start === false) {
73
-      return $string;
74
-    }
75
-    $end = strpos($string, "}");
76
-    if ($end === false) {
77
-      return $string;
78
-    }
79
-    $string = $this->replace($string, $start, $end, $parameters);
80
-    return $this->resolveNextSection($string, $parameters);
71
+	$start = strpos($string, "{");
72
+	if ($start === false) {
73
+	  return $string;
74
+	}
75
+	$end = strpos($string, "}");
76
+	if ($end === false) {
77
+	  return $string;
78
+	}
79
+	$string = $this->replace($string, $start, $end, $parameters);
80
+	return $this->resolveNextSection($string, $parameters);
81 81
   }
82 82
 
83 83
   private function replace($string, $start, $end, $parameters)
84 84
   {
85
-    // We know a data block will have {} round it, so we can strip that.
86
-    $data = substr($string, $start + 1, $end - $start - 1);
85
+	// We know a data block will have {} round it, so we can strip that.
86
+	$data = substr($string, $start + 1, $end - $start - 1);
87 87
 
88
-    // If the first character is one of the reserved operators, it effects
89
-    // the processing of the stream.
90
-    if (isset($this->operators[$data[0]])) {
91
-      $op = $this->operators[$data[0]];
92
-      $data = substr($data, 1);
93
-      $prefix = "";
94
-      $prefix_on_missing = false;
88
+	// If the first character is one of the reserved operators, it effects
89
+	// the processing of the stream.
90
+	if (isset($this->operators[$data[0]])) {
91
+	  $op = $this->operators[$data[0]];
92
+	  $data = substr($data, 1);
93
+	  $prefix = "";
94
+	  $prefix_on_missing = false;
95 95
 
96
-      switch ($op) {
97
-        case "reserved":
98
-          // Reserved means certain characters should not be URL encoded
99
-          $data = $this->replaceVars($data, $parameters, ",", null, true);
100
-          break;
101
-        case "fragment":
102
-          // Comma separated with fragment prefix. Bare values only.
103
-          $prefix = "#";
104
-          $prefix_on_missing = true;
105
-          $data = $this->replaceVars($data, $parameters, ",", null, true);
106
-          break;
107
-        case "segments":
108
-          // Slash separated data. Bare values only.
109
-          $prefix = "/";
110
-          $data =$this->replaceVars($data, $parameters, "/");
111
-          break;
112
-        case "dotprefix":
113
-          // Dot separated data. Bare values only.
114
-          $prefix = ".";
115
-          $prefix_on_missing = true;
116
-          $data = $this->replaceVars($data, $parameters, ".");
117
-          break;
118
-        case "semicolon":
119
-          // Semicolon prefixed and separated. Uses the key name
120
-          $prefix = ";";
121
-          $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false);
122
-          break;
123
-        case "form":
124
-          // Standard URL format. Uses the key name
125
-          $prefix = "?";
126
-          $data = $this->replaceVars($data, $parameters, "&", "=");
127
-          break;
128
-        case "continuation":
129
-          // Standard URL, but with leading ampersand. Uses key name.
130
-          $prefix = "&";
131
-          $data = $this->replaceVars($data, $parameters, "&", "=");
132
-          break;
133
-      }
96
+	  switch ($op) {
97
+		case "reserved":
98
+		  // Reserved means certain characters should not be URL encoded
99
+		  $data = $this->replaceVars($data, $parameters, ",", null, true);
100
+		  break;
101
+		case "fragment":
102
+		  // Comma separated with fragment prefix. Bare values only.
103
+		  $prefix = "#";
104
+		  $prefix_on_missing = true;
105
+		  $data = $this->replaceVars($data, $parameters, ",", null, true);
106
+		  break;
107
+		case "segments":
108
+		  // Slash separated data. Bare values only.
109
+		  $prefix = "/";
110
+		  $data =$this->replaceVars($data, $parameters, "/");
111
+		  break;
112
+		case "dotprefix":
113
+		  // Dot separated data. Bare values only.
114
+		  $prefix = ".";
115
+		  $prefix_on_missing = true;
116
+		  $data = $this->replaceVars($data, $parameters, ".");
117
+		  break;
118
+		case "semicolon":
119
+		  // Semicolon prefixed and separated. Uses the key name
120
+		  $prefix = ";";
121
+		  $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false);
122
+		  break;
123
+		case "form":
124
+		  // Standard URL format. Uses the key name
125
+		  $prefix = "?";
126
+		  $data = $this->replaceVars($data, $parameters, "&", "=");
127
+		  break;
128
+		case "continuation":
129
+		  // Standard URL, but with leading ampersand. Uses key name.
130
+		  $prefix = "&";
131
+		  $data = $this->replaceVars($data, $parameters, "&", "=");
132
+		  break;
133
+	  }
134 134
 
135
-      // Add the initial prefix character if data is valid.
136
-      if ($data || ($data !== false && $prefix_on_missing)) {
137
-        $data = $prefix . $data;
138
-      }
135
+	  // Add the initial prefix character if data is valid.
136
+	  if ($data || ($data !== false && $prefix_on_missing)) {
137
+		$data = $prefix . $data;
138
+	  }
139 139
 
140
-    } else {
141
-      // If no operator we replace with the defaults.
142
-      $data = $this->replaceVars($data, $parameters);
143
-    }
144
-    // This is chops out the {...} and replaces with the new section.
145
-    return substr($string, 0, $start) . $data . substr($string, $end + 1);
140
+	} else {
141
+	  // If no operator we replace with the defaults.
142
+	  $data = $this->replaceVars($data, $parameters);
143
+	}
144
+	// This is chops out the {...} and replaces with the new section.
145
+	return substr($string, 0, $start) . $data . substr($string, $end + 1);
146 146
   }
147 147
 
148 148
   private function replaceVars(
149
-      $section,
150
-      $parameters,
151
-      $sep = ",",
152
-      $combine = null,
153
-      $reserved = false,
154
-      $tag_empty = false,
155
-      $combine_on_empty = true
149
+	  $section,
150
+	  $parameters,
151
+	  $sep = ",",
152
+	  $combine = null,
153
+	  $reserved = false,
154
+	  $tag_empty = false,
155
+	  $combine_on_empty = true
156 156
   ) {
157
-    if (strpos($section, ",") === false) {
158
-      // If we only have a single value, we can immediately process.
159
-      return $this->combine(
160
-          $section,
161
-          $parameters,
162
-          $sep,
163
-          $combine,
164
-          $reserved,
165
-          $tag_empty,
166
-          $combine_on_empty
167
-      );
168
-    } else {
169
-      // If we have multiple values, we need to split and loop over them.
170
-      // Each is treated individually, then glued together with the
171
-      // separator character.
172
-      $vars = explode(",", $section);
173
-      return $this->combineList(
174
-          $vars,
175
-          $sep,
176
-          $parameters,
177
-          $combine,
178
-          $reserved,
179
-          false, // Never emit empty strings in multi-param replacements
180
-          $combine_on_empty
181
-      );
182
-    }
157
+	if (strpos($section, ",") === false) {
158
+	  // If we only have a single value, we can immediately process.
159
+	  return $this->combine(
160
+		  $section,
161
+		  $parameters,
162
+		  $sep,
163
+		  $combine,
164
+		  $reserved,
165
+		  $tag_empty,
166
+		  $combine_on_empty
167
+	  );
168
+	} else {
169
+	  // If we have multiple values, we need to split and loop over them.
170
+	  // Each is treated individually, then glued together with the
171
+	  // separator character.
172
+	  $vars = explode(",", $section);
173
+	  return $this->combineList(
174
+		  $vars,
175
+		  $sep,
176
+		  $parameters,
177
+		  $combine,
178
+		  $reserved,
179
+		  false, // Never emit empty strings in multi-param replacements
180
+		  $combine_on_empty
181
+	  );
182
+	}
183 183
   }
184 184
  
185 185
   public function combine(
186
-      $key,
187
-      $parameters,
188
-      $sep,
189
-      $combine,
190
-      $reserved,
191
-      $tag_empty,
192
-      $combine_on_empty
186
+	  $key,
187
+	  $parameters,
188
+	  $sep,
189
+	  $combine,
190
+	  $reserved,
191
+	  $tag_empty,
192
+	  $combine_on_empty
193 193
   ) {
194
-    $length = false;
195
-    $explode = false;
196
-    $skip_final_combine = false;
197
-    $value = false;
194
+	$length = false;
195
+	$explode = false;
196
+	$skip_final_combine = false;
197
+	$value = false;
198 198
 
199
-    // Check for length restriction.
200
-    if (strpos($key, ":") !== false) {
201
-      list($key, $length) = explode(":", $key);
202
-    }
199
+	// Check for length restriction.
200
+	if (strpos($key, ":") !== false) {
201
+	  list($key, $length) = explode(":", $key);
202
+	}
203 203
     
204
-    // Check for explode parameter.
205
-    if ($key[strlen($key) - 1] == "*") {
206
-      $explode = true;
207
-      $key = substr($key, 0, -1);
208
-      $skip_final_combine = true;
209
-    }
204
+	// Check for explode parameter.
205
+	if ($key[strlen($key) - 1] == "*") {
206
+	  $explode = true;
207
+	  $key = substr($key, 0, -1);
208
+	  $skip_final_combine = true;
209
+	}
210 210
     
211
-    // Define the list separator.
212
-    $list_sep = $explode ? $sep : ",";
211
+	// Define the list separator.
212
+	$list_sep = $explode ? $sep : ",";
213 213
     
214
-    if (isset($parameters[$key])) {
215
-      $data_type = $this->getDataType($parameters[$key]);
216
-      switch ($data_type) {
217
-        case self::TYPE_SCALAR:
218
-          $value = $this->getValue($parameters[$key], $length);
219
-          break;
220
-        case self::TYPE_LIST:
221
-          $values = array();
222
-          foreach ($parameters[$key] as $pkey => $pvalue) {
223
-            $pvalue = $this->getValue($pvalue, $length);
224
-            if ($combine && $explode) {
225
-              $values[$pkey] = $key . $combine . $pvalue;
226
-            } else {
227
-              $values[$pkey] = $pvalue;
228
-            }
229
-          }
230
-          $value = implode($list_sep, $values);
231
-          if ($value == '') {
232
-            return '';
233
-          }
234
-          break;
235
-        case self::TYPE_MAP:
236
-          $values = array();
237
-          foreach ($parameters[$key] as $pkey => $pvalue) {
238
-            $pvalue = $this->getValue($pvalue, $length);
239
-            if ($explode) {
240
-              $pkey = $this->getValue($pkey, $length);
241
-              $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
242
-            } else {
243
-              $values[] = $pkey;
244
-              $values[] = $pvalue;
245
-            }
246
-          }
247
-          $value = implode($list_sep, $values);
248
-          if ($value == '') {
249
-            return false;
250
-          }
251
-          break;
252
-      }
253
-    } else if ($tag_empty) {
254
-      // If we are just indicating empty values with their key name, return that.
255
-      return $key;
256
-    } else {
257
-      // Otherwise we can skip this variable due to not being defined.
258
-      return false;
259
-    }
214
+	if (isset($parameters[$key])) {
215
+	  $data_type = $this->getDataType($parameters[$key]);
216
+	  switch ($data_type) {
217
+		case self::TYPE_SCALAR:
218
+		  $value = $this->getValue($parameters[$key], $length);
219
+		  break;
220
+		case self::TYPE_LIST:
221
+		  $values = array();
222
+		  foreach ($parameters[$key] as $pkey => $pvalue) {
223
+			$pvalue = $this->getValue($pvalue, $length);
224
+			if ($combine && $explode) {
225
+			  $values[$pkey] = $key . $combine . $pvalue;
226
+			} else {
227
+			  $values[$pkey] = $pvalue;
228
+			}
229
+		  }
230
+		  $value = implode($list_sep, $values);
231
+		  if ($value == '') {
232
+			return '';
233
+		  }
234
+		  break;
235
+		case self::TYPE_MAP:
236
+		  $values = array();
237
+		  foreach ($parameters[$key] as $pkey => $pvalue) {
238
+			$pvalue = $this->getValue($pvalue, $length);
239
+			if ($explode) {
240
+			  $pkey = $this->getValue($pkey, $length);
241
+			  $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
242
+			} else {
243
+			  $values[] = $pkey;
244
+			  $values[] = $pvalue;
245
+			}
246
+		  }
247
+		  $value = implode($list_sep, $values);
248
+		  if ($value == '') {
249
+			return false;
250
+		  }
251
+		  break;
252
+	  }
253
+	} else if ($tag_empty) {
254
+	  // If we are just indicating empty values with their key name, return that.
255
+	  return $key;
256
+	} else {
257
+	  // Otherwise we can skip this variable due to not being defined.
258
+	  return false;
259
+	}
260 260
 
261
-    if ($reserved) {
262
-      $value = str_replace($this->reservedEncoded, $this->reserved, $value);
263
-    }
261
+	if ($reserved) {
262
+	  $value = str_replace($this->reservedEncoded, $this->reserved, $value);
263
+	}
264 264
 
265
-    // If we do not need to include the key name, we just return the raw
266
-    // value.
267
-    if (!$combine || $skip_final_combine) {
268
-      return $value;
269
-    }
265
+	// If we do not need to include the key name, we just return the raw
266
+	// value.
267
+	if (!$combine || $skip_final_combine) {
268
+	  return $value;
269
+	}
270 270
         
271
-    // Else we combine the key name: foo=bar, if value is not the empty string.
272
-    return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
271
+	// Else we combine the key name: foo=bar, if value is not the empty string.
272
+	return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
273 273
   }
274 274
   
275 275
   /**
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
    */
278 278
   private function getDataType($data)
279 279
   {
280
-    if (is_array($data)) {
281
-      reset($data);
282
-      if (key($data) !== 0) {
283
-        return self::TYPE_MAP;
284
-      }
285
-      return self::TYPE_LIST;
286
-    }
287
-    return self::TYPE_SCALAR;
280
+	if (is_array($data)) {
281
+	  reset($data);
282
+	  if (key($data) !== 0) {
283
+		return self::TYPE_MAP;
284
+	  }
285
+	  return self::TYPE_LIST;
286
+	}
287
+	return self::TYPE_SCALAR;
288 288
   }
289 289
   
290 290
   /**
@@ -292,31 +292,31 @@  discard block
 block discarded – undo
292 292
    * for multi-key templates.
293 293
    */
294 294
   private function combineList(
295
-      $vars,
296
-      $sep,
297
-      $parameters,
298
-      $combine,
299
-      $reserved,
300
-      $tag_empty,
301
-      $combine_on_empty
295
+	  $vars,
296
+	  $sep,
297
+	  $parameters,
298
+	  $combine,
299
+	  $reserved,
300
+	  $tag_empty,
301
+	  $combine_on_empty
302 302
   ) {
303
-    $ret = array();
304
-    foreach ($vars as $var) {
305
-      $response = $this->combine(
306
-          $var,
307
-          $parameters,
308
-          $sep,
309
-          $combine,
310
-          $reserved,
311
-          $tag_empty,
312
-          $combine_on_empty
313
-      );
314
-      if ($response === false) {
315
-        continue;
316
-      }
317
-      $ret[] = $response;
318
-    }
319
-    return implode($sep, $ret);
303
+	$ret = array();
304
+	foreach ($vars as $var) {
305
+	  $response = $this->combine(
306
+		  $var,
307
+		  $parameters,
308
+		  $sep,
309
+		  $combine,
310
+		  $reserved,
311
+		  $tag_empty,
312
+		  $combine_on_empty
313
+	  );
314
+	  if ($response === false) {
315
+		continue;
316
+	  }
317
+	  $ret[] = $response;
318
+	}
319
+	return implode($sep, $ret);
320 320
   }
321 321
   
322 322
   /**
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
    */
325 325
   private function getValue($value, $length)
326 326
   {
327
-    if ($length) {
328
-      $value = substr($value, 0, $length);
329
-    }
330
-    $value = rawurlencode($value);
331
-    return $value;
327
+	if ($length) {
328
+	  $value = substr($value, 0, $length);
329
+	}
330
+	$value = rawurlencode($value);
331
+	return $value;
332 332
   }
333 333
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
    */
49 49
   private $reserved = array(
50 50
       "=", ",", "!", "@", "|", ":", "/", "?", "#",
51
-      "[", "]",'$', "&", "'", "(", ")", "*", "+", ";"
51
+      "[", "]", '$', "&", "'", "(", ")", "*", "+", ";"
52 52
   );
53 53
   private $reservedEncoded = array(
54 54
     "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         case "segments":
108 108
           // Slash separated data. Bare values only.
109 109
           $prefix = "/";
110
-          $data =$this->replaceVars($data, $parameters, "/");
110
+          $data = $this->replaceVars($data, $parameters, "/");
111 111
           break;
112 112
         case "dotprefix":
113 113
           // Dot separated data. Bare values only.
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
       // Add the initial prefix character if data is valid.
136 136
       if ($data || ($data !== false && $prefix_on_missing)) {
137
-        $data = $prefix . $data;
137
+        $data = $prefix.$data;
138 138
       }
139 139
 
140 140
     } else {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
       $data = $this->replaceVars($data, $parameters);
143 143
     }
144 144
     // This is chops out the {...} and replaces with the new section.
145
-    return substr($string, 0, $start) . $data . substr($string, $end + 1);
145
+    return substr($string, 0, $start).$data.substr($string, $end + 1);
146 146
   }
147 147
 
148 148
   private function replaceVars(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
           foreach ($parameters[$key] as $pkey => $pvalue) {
223 223
             $pvalue = $this->getValue($pvalue, $length);
224 224
             if ($combine && $explode) {
225
-              $values[$pkey] = $key . $combine . $pvalue;
225
+              $values[$pkey] = $key.$combine.$pvalue;
226 226
             } else {
227 227
               $values[$pkey] = $pvalue;
228 228
             }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             $pvalue = $this->getValue($pvalue, $length);
239 239
             if ($explode) {
240 240
               $pkey = $this->getValue($pkey, $length);
241
-              $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
241
+              $values[] = $pkey."=".$pvalue; // Explode triggers = combine.
242 242
             } else {
243 243
               $values[] = $pkey;
244 244
               $values[] = $pvalue;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     }
270 270
         
271 271
     // Else we combine the key name: foo=bar, if value is not the empty string.
272
-    return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
272
+    return $key.($value != '' || $combine_on_empty ? $combine.$value : '');
273 273
   }
274 274
   
275 275
   /**
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/LoginTicket.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
    */
43 43
   public function __construct($envelope, $payload)
44 44
   {
45
-    $this->envelope = $envelope;
46
-    $this->payload = $payload;
45
+	$this->envelope = $envelope;
46
+	$this->payload = $payload;
47 47
   }
48 48
 
49 49
   /**
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
    */
54 54
   public function getUserId()
55 55
   {
56
-    if (array_key_exists(self::USER_ATTR, $this->payload)) {
57
-      return $this->payload[self::USER_ATTR];
58
-    }
59
-    throw new Google_Auth_Exception("No user_id in token");
56
+	if (array_key_exists(self::USER_ATTR, $this->payload)) {
57
+	  return $this->payload[self::USER_ATTR];
58
+	}
59
+	throw new Google_Auth_Exception("No user_id in token");
60 60
   }
61 61
 
62 62
   /**
@@ -66,6 +66,6 @@  discard block
 block discarded – undo
66 66
    */
67 67
   public function getAttributes()
68 68
   {
69
-    return array("envelope" => $this->envelope, "payload" => $this->payload);
69
+	return array("envelope" => $this->envelope, "payload" => $this->payload);
70 70
   }
71 71
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
Please login to merge, or discard this patch.
google-api-php-client/src/Google/Auth/AssertionCredentials.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -51,22 +51,22 @@  discard block
 block discarded – undo
51 51
    *              automatic caching of the generated token.
52 52
    */
53 53
   public function __construct(
54
-      $serviceAccountName,
55
-      $scopes,
56
-      $privateKey,
57
-      $privateKeyPassword = 'notasecret',
58
-      $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
59
-      $sub = false,
60
-      $useCache = true
54
+	  $serviceAccountName,
55
+	  $scopes,
56
+	  $privateKey,
57
+	  $privateKeyPassword = 'notasecret',
58
+	  $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
59
+	  $sub = false,
60
+	  $useCache = true
61 61
   ) {
62
-    $this->serviceAccountName = $serviceAccountName;
63
-    $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
64
-    $this->privateKey = $privateKey;
65
-    $this->privateKeyPassword = $privateKeyPassword;
66
-    $this->assertionType = $assertionType;
67
-    $this->sub = $sub;
68
-    $this->prn = $sub;
69
-    $this->useCache = $useCache;
62
+	$this->serviceAccountName = $serviceAccountName;
63
+	$this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
64
+	$this->privateKey = $privateKey;
65
+	$this->privateKeyPassword = $privateKeyPassword;
66
+	$this->assertionType = $assertionType;
67
+	$this->sub = $sub;
68
+	$this->prn = $sub;
69
+	$this->useCache = $useCache;
70 70
   }
71 71
   
72 72
   /**
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
    */
76 76
   public function getCacheKey()
77 77
   {
78
-    if (!$this->useCache) {
79
-      return false;
80
-    }
81
-    $h = $this->sub;
82
-    $h .= $this->assertionType;
83
-    $h .= $this->privateKey;
84
-    $h .= $this->scopes;
85
-    $h .= $this->serviceAccountName;
86
-    return md5($h);
78
+	if (!$this->useCache) {
79
+	  return false;
80
+	}
81
+	$h = $this->sub;
82
+	$h .= $this->assertionType;
83
+	$h .= $this->privateKey;
84
+	$h .= $this->scopes;
85
+	$h .= $this->serviceAccountName;
86
+	return md5($h);
87 87
   }
88 88
 
89 89
   public function generateAssertion()
90 90
   {
91
-    $now = time();
91
+	$now = time();
92 92
 
93
-    $jwtParams = array(
94
-          'aud' => Google_Auth_OAuth2::OAUTH2_TOKEN_URI,
95
-          'scope' => $this->scopes,
96
-          'iat' => $now,
97
-          'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
98
-          'iss' => $this->serviceAccountName,
99
-    );
93
+	$jwtParams = array(
94
+		  'aud' => Google_Auth_OAuth2::OAUTH2_TOKEN_URI,
95
+		  'scope' => $this->scopes,
96
+		  'iat' => $now,
97
+		  'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
98
+		  'iss' => $this->serviceAccountName,
99
+	);
100 100
 
101
-    if ($this->sub !== false) {
102
-      $jwtParams['sub'] = $this->sub;
103
-    } else if ($this->prn !== false) {
104
-      $jwtParams['prn'] = $this->prn;
105
-    }
101
+	if ($this->sub !== false) {
102
+	  $jwtParams['sub'] = $this->sub;
103
+	} else if ($this->prn !== false) {
104
+	  $jwtParams['prn'] = $this->prn;
105
+	}
106 106
 
107
-    return $this->makeSignedJwt($jwtParams);
107
+	return $this->makeSignedJwt($jwtParams);
108 108
   }
109 109
 
110 110
   /**
@@ -114,23 +114,23 @@  discard block
 block discarded – undo
114 114
    */
115 115
   private function makeSignedJwt($payload)
116 116
   {
117
-    $header = array('typ' => 'JWT', 'alg' => 'RS256');
117
+	$header = array('typ' => 'JWT', 'alg' => 'RS256');
118 118
 
119
-    $payload = json_encode($payload);
120
-    // Handle some overzealous escaping in PHP json that seemed to cause some errors
121
-    // with claimsets.
122
-    $payload = str_replace('\/', '/', $payload);
119
+	$payload = json_encode($payload);
120
+	// Handle some overzealous escaping in PHP json that seemed to cause some errors
121
+	// with claimsets.
122
+	$payload = str_replace('\/', '/', $payload);
123 123
 
124
-    $segments = array(
125
-      Google_Utils::urlSafeB64Encode(json_encode($header)),
126
-      Google_Utils::urlSafeB64Encode($payload)
127
-    );
124
+	$segments = array(
125
+	  Google_Utils::urlSafeB64Encode(json_encode($header)),
126
+	  Google_Utils::urlSafeB64Encode($payload)
127
+	);
128 128
 
129
-    $signingInput = implode('.', $segments);
130
-    $signer = new Google_Signer_P12($this->privateKey, $this->privateKeyPassword);
131
-    $signature = $signer->sign($signingInput);
132
-    $segments[] = Google_Utils::urlSafeB64Encode($signature);
129
+	$signingInput = implode('.', $segments);
130
+	$signer = new Google_Signer_P12($this->privateKey, $this->privateKeyPassword);
131
+	$signature = $signer->sign($signingInput);
132
+	$segments[] = Google_Utils::urlSafeB64Encode($signature);
133 133
 
134
-    return implode(".", $segments);
134
+	return implode(".", $segments);
135 135
   }
136 136
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/AppIdentity.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
   public function __construct(Google_Client $client, $config = null)
40 40
   {
41
-    $this->client = $client;
41
+	$this->client = $client;
42 42
   }
43 43
 
44 44
   /**
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
    */
47 47
   public function authenticateForScope($scopes)
48 48
   {
49
-    if ($this->token && $this->tokenScopes == $scopes) {
50
-      return $this->token;
51
-    }
49
+	if ($this->token && $this->tokenScopes == $scopes) {
50
+	  return $this->token;
51
+	}
52 52
 
53
-    $cacheKey = self::CACHE_PREFIX;
54
-    if (is_string($scopes)) {
55
-      $cacheKey .= $scopes;
56
-    } else if (is_array($scopes)) {
57
-      $cacheKey .= implode(":", $scopes);
58
-    }
53
+	$cacheKey = self::CACHE_PREFIX;
54
+	if (is_string($scopes)) {
55
+	  $cacheKey .= $scopes;
56
+	} else if (is_array($scopes)) {
57
+	  $cacheKey .= implode(":", $scopes);
58
+	}
59 59
 
60
-    $this->token = $this->client->getCache()->get($cacheKey);
61
-    if (!$this->token) {
62
-      $this->retrieveToken($scopes, $cacheKey);
63
-    } else if ($this->token['expiration_time'] < time()) {
64
-      $this->client->getCache()->delete($cacheKey);
65
-      $this->retrieveToken($scopes, $cacheKey);
66
-    }
60
+	$this->token = $this->client->getCache()->get($cacheKey);
61
+	if (!$this->token) {
62
+	  $this->retrieveToken($scopes, $cacheKey);
63
+	} else if ($this->token['expiration_time'] < time()) {
64
+	  $this->client->getCache()->delete($cacheKey);
65
+	  $this->retrieveToken($scopes, $cacheKey);
66
+	}
67 67
 
68
-    $this->tokenScopes = $scopes;
69
-    return $this->token;
68
+	$this->tokenScopes = $scopes;
69
+	return $this->token;
70 70
   }
71 71
 
72 72
   /**
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
    */
77 77
   private function retrieveToken($scopes, $cacheKey)
78 78
   {
79
-    $this->token = AppIdentityService::getAccessToken($scopes);
80
-    if ($this->token) {
81
-      $this->client->getCache()->set(
82
-          $cacheKey,
83
-          $this->token
84
-      );
85
-    }
79
+	$this->token = AppIdentityService::getAccessToken($scopes);
80
+	if ($this->token) {
81
+	  $this->client->getCache()->set(
82
+		  $cacheKey,
83
+		  $this->token
84
+	  );
85
+	}
86 86
   }
87 87
 
88 88
   /**
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
    */
98 98
   public function authenticatedRequest(Google_Http_Request $request)
99 99
   {
100
-    $request = $this->sign($request);
101
-    return $this->client->getIo()->makeRequest($request);
100
+	$request = $this->sign($request);
101
+	return $this->client->getIo()->makeRequest($request);
102 102
   }
103 103
 
104 104
   public function sign(Google_Http_Request $request)
105 105
   {
106
-    if (!$this->token) {
107
-      // No token, so nothing to do.
108
-      return $request;
109
-    }
106
+	if (!$this->token) {
107
+	  // No token, so nothing to do.
108
+	  return $request;
109
+	}
110 110
 
111
-    $this->client->getLogger()->debug('App Identity authentication');
111
+	$this->client->getLogger()->debug('App Identity authentication');
112 112
 
113
-    // Add the OAuth2 header to the request
114
-    $request->setRequestHeaders(
115
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
116
-    );
113
+	// Add the OAuth2 header to the request
114
+	$request->setRequestHeaders(
115
+		array('Authorization' => 'Bearer ' . $this->token['access_token'])
116
+	);
117 117
 
118
-    return $request;
118
+	return $request;
119 119
   }
120 120
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 use google\appengine\api\app_identity\AppIdentityService;
24 24
 
25 25
 if (!class_exists('Google_Client')) {
26
-  require_once dirname(__FILE__) . '/../autoload.php';
26
+  require_once dirname(__FILE__).'/../autoload.php';
27 27
 }
28 28
 
29 29
 /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
     // Add the OAuth2 header to the request
114 114
     $request->setRequestHeaders(
115
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
115
+        array('Authorization' => 'Bearer '.$this->token['access_token'])
116 116
     );
117 117
 
118 118
     return $request;
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/Simple.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
   public function __construct(Google_Client $client, $config = null)
32 32
   {
33
-    $this->client = $client;
33
+	$this->client = $client;
34 34
   }
35 35
 
36 36
   /**
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
    */
46 46
   public function authenticatedRequest(Google_Http_Request $request)
47 47
   {
48
-    $request = $this->sign($request);
49
-    return $this->io->makeRequest($request);
48
+	$request = $this->sign($request);
49
+	return $this->io->makeRequest($request);
50 50
   }
51 51
 
52 52
   public function sign(Google_Http_Request $request)
53 53
   {
54
-    $key = $this->client->getClassConfig($this, 'developer_key');
55
-    if ($key) {
56
-      $this->client->getLogger()->debug(
57
-          'Simple API Access developer key authentication'
58
-      );
59
-      $request->setQueryParam('key', $key);
60
-    }
61
-    return $request;
54
+	$key = $this->client->getClassConfig($this, 'developer_key');
55
+	if ($key) {
56
+	  $this->client->getLogger()->debug(
57
+		  'Simple API Access developer key authentication'
58
+	  );
59
+	  $request->setQueryParam('key', $key);
60
+	}
61
+	return $request;
62 62
   }
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 class Google_Auth_Exception extends Google_Exception
Please login to merge, or discard this patch.
geodirectory-admin/google-api-php-client/src/Google/Auth/ComputeEngine.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 class Google_Auth_ComputeEngine extends Google_Auth_Abstract
29 29
 {
30 30
   const METADATA_AUTH_URL =
31
-      'http://metadata/computeMetadata/v1/instance/service-accounts/default/token';
31
+	  'http://metadata/computeMetadata/v1/instance/service-accounts/default/token';
32 32
   private $client;
33 33
   private $token;
34 34
 
35 35
   public function __construct(Google_Client $client, $config = null)
36 36
   {
37
-    $this->client = $client;
37
+	$this->client = $client;
38 38
   }
39 39
 
40 40
   /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
    */
50 50
   public function authenticatedRequest(Google_Http_Request $request)
51 51
   {
52
-    $request = $this->sign($request);
53
-    return $this->client->getIo()->makeRequest($request);
52
+	$request = $this->sign($request);
53
+	return $this->client->getIo()->makeRequest($request);
54 54
   }
55 55
 
56 56
   /**
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
    */
60 60
   public function setAccessToken($token)
61 61
   {
62
-    $token = json_decode($token, true);
63
-    if ($token == null) {
64
-      throw new Google_Auth_Exception('Could not json decode the token');
65
-    }
66
-    if (! isset($token['access_token'])) {
67
-      throw new Google_Auth_Exception("Invalid token format");
68
-    }
69
-    $token['created'] = time();
70
-    $this->token = $token;
62
+	$token = json_decode($token, true);
63
+	if ($token == null) {
64
+	  throw new Google_Auth_Exception('Could not json decode the token');
65
+	}
66
+	if (! isset($token['access_token'])) {
67
+	  throw new Google_Auth_Exception("Invalid token format");
68
+	}
69
+	$token['created'] = time();
70
+	$this->token = $token;
71 71
   }
72 72
 
73 73
   public function getAccessToken()
74 74
   {
75
-    return json_encode($this->token);
75
+	return json_encode($this->token);
76 76
   }
77 77
 
78 78
   /**
@@ -81,29 +81,29 @@  discard block
 block discarded – undo
81 81
    */
82 82
   public function acquireAccessToken()
83 83
   {
84
-    $request = new Google_Http_Request(
85
-        self::METADATA_AUTH_URL,
86
-        'GET',
87
-        array(
88
-          'Metadata-Flavor' => 'Google'
89
-        )
90
-    );
91
-    $request->disableGzip();
92
-    $response = $this->client->getIo()->makeRequest($request);
84
+	$request = new Google_Http_Request(
85
+		self::METADATA_AUTH_URL,
86
+		'GET',
87
+		array(
88
+		  'Metadata-Flavor' => 'Google'
89
+		)
90
+	);
91
+	$request->disableGzip();
92
+	$response = $this->client->getIo()->makeRequest($request);
93 93
 
94
-    if ($response->getResponseHttpCode() == 200) {
95
-      $this->setAccessToken($response->getResponseBody());
96
-      $this->token['created'] = time();
97
-      return $this->getAccessToken();
98
-    } else {
99
-      throw new Google_Auth_Exception(
100
-          sprintf(
101
-              "Error fetching service account access token, message: '%s'",
102
-              $response->getResponseBody()
103
-          ),
104
-          $response->getResponseHttpCode()
105
-      );
106
-    }
94
+	if ($response->getResponseHttpCode() == 200) {
95
+	  $this->setAccessToken($response->getResponseBody());
96
+	  $this->token['created'] = time();
97
+	  return $this->getAccessToken();
98
+	} else {
99
+	  throw new Google_Auth_Exception(
100
+		  sprintf(
101
+			  "Error fetching service account access token, message: '%s'",
102
+			  $response->getResponseBody()
103
+		  ),
104
+		  $response->getResponseHttpCode()
105
+	  );
106
+	}
107 107
   }
108 108
 
109 109
   /**
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
    */
115 115
   public function sign(Google_Http_Request $request)
116 116
   {
117
-    if ($this->isAccessTokenExpired()) {
118
-      $this->acquireAccessToken();
119
-    }
117
+	if ($this->isAccessTokenExpired()) {
118
+	  $this->acquireAccessToken();
119
+	}
120 120
 
121
-    $this->client->getLogger()->debug('Compute engine service account authentication');
121
+	$this->client->getLogger()->debug('Compute engine service account authentication');
122 122
 
123
-    $request->setRequestHeaders(
124
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
125
-    );
123
+	$request->setRequestHeaders(
124
+		array('Authorization' => 'Bearer ' . $this->token['access_token'])
125
+	);
126 126
 
127
-    return $request;
127
+	return $request;
128 128
   }
129 129
 
130 130
   /**
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
    */
134 134
   public function isAccessTokenExpired()
135 135
   {
136
-    if (!$this->token || !isset($this->token['created'])) {
137
-      return true;
138
-    }
136
+	if (!$this->token || !isset($this->token['created'])) {
137
+	  return true;
138
+	}
139 139
 
140
-    // If the token is set to expire in the next 30 seconds.
141
-    $expired = ($this->token['created']
142
-        + ($this->token['expires_in'] - 30)) < time();
140
+	// If the token is set to expire in the next 30 seconds.
141
+	$expired = ($this->token['created']
142
+		+ ($this->token['expires_in'] - 30)) < time();
143 143
 
144
-    return $expired;
144
+	return $expired;
145 145
   }
146 146
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!class_exists('Google_Client')) {
19
-  require_once dirname(__FILE__) . '/../autoload.php';
19
+  require_once dirname(__FILE__).'/../autoload.php';
20 20
 }
21 21
 
22 22
 /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     if ($token == null) {
64 64
       throw new Google_Auth_Exception('Could not json decode the token');
65 65
     }
66
-    if (! isset($token['access_token'])) {
66
+    if (!isset($token['access_token'])) {
67 67
       throw new Google_Auth_Exception("Invalid token format");
68 68
     }
69 69
     $token['created'] = time();
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     $this->client->getLogger()->debug('Compute engine service account authentication');
122 122
 
123 123
     $request->setRequestHeaders(
124
-        array('Authorization' => 'Bearer ' . $this->token['access_token'])
124
+        array('Authorization' => 'Bearer '.$this->token['access_token'])
125 125
     );
126 126
 
127 127
     return $request;
Please login to merge, or discard this patch.