@@ -23,4 +23,4 @@ |
||
23 | 23 | $error = "google-api-php-client's autoloader was moved to src/Google/autoload.php in 1.1.3. This "; |
24 | 24 | $error .= "redirect will be removed in 1.2. Please adjust your code to use the new location."; |
25 | 25 | trigger_error($error, E_USER_DEPRECATED); |
26 | -require_once dirname(__FILE__) . '/src/Google/autoload.php'; |
|
26 | +require_once dirname(__FILE__).'/src/Google/autoload.php'; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct(Google_Client $client) |
29 | 29 | { |
30 | - $this->client = $client; |
|
30 | + $this->client = $client; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getClient() |
38 | 38 | { |
39 | - return $this->client; |
|
39 | + return $this->client; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function createBatch() |
48 | 48 | { |
49 | - return new Google_Http_Batch( |
|
50 | - $this->client, |
|
51 | - false, |
|
52 | - $this->rootUrl, |
|
53 | - $this->batchPath |
|
54 | - ); |
|
49 | + return new Google_Http_Batch( |
|
50 | + $this->client, |
|
51 | + false, |
|
52 | + $this->rootUrl, |
|
53 | + $this->batchPath |
|
54 | + ); |
|
55 | 55 | } |
56 | 56 | } |
@@ -23,23 +23,23 @@ discard block |
||
23 | 23 | { |
24 | 24 | public static function urlSafeB64Encode($data) |
25 | 25 | { |
26 | - $b64 = base64_encode($data); |
|
27 | - $b64 = str_replace( |
|
28 | - array('+', '/', '\r', '\n', '='), |
|
29 | - array('-', '_'), |
|
30 | - $b64 |
|
31 | - ); |
|
32 | - return $b64; |
|
26 | + $b64 = base64_encode($data); |
|
27 | + $b64 = str_replace( |
|
28 | + array('+', '/', '\r', '\n', '='), |
|
29 | + array('-', '_'), |
|
30 | + $b64 |
|
31 | + ); |
|
32 | + return $b64; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function urlSafeB64Decode($b64) |
36 | 36 | { |
37 | - $b64 = str_replace( |
|
38 | - array('-', '_'), |
|
39 | - array('+', '/'), |
|
40 | - $b64 |
|
41 | - ); |
|
42 | - return base64_decode($b64); |
|
37 | + $b64 = str_replace( |
|
38 | + array('-', '_'), |
|
39 | + array('+', '/'), |
|
40 | + $b64 |
|
41 | + ); |
|
42 | + return base64_decode($b64); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -59,45 +59,45 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function getStrLen($str) |
61 | 61 | { |
62 | - $strlenVar = strlen($str); |
|
63 | - $d = $ret = 0; |
|
64 | - for ($count = 0; $count < $strlenVar; ++ $count) { |
|
65 | - $ordinalValue = ord($str{$ret}); |
|
66 | - switch (true) { |
|
67 | - case (($ordinalValue >= 0x20) && ($ordinalValue <= 0x7F)): |
|
68 | - // characters U-00000000 - U-0000007F (same as ASCII) |
|
69 | - $ret ++; |
|
70 | - break; |
|
71 | - case (($ordinalValue & 0xE0) == 0xC0): |
|
72 | - // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
73 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
74 | - $ret += 2; |
|
75 | - break; |
|
76 | - case (($ordinalValue & 0xF0) == 0xE0): |
|
77 | - // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
78 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
79 | - $ret += 3; |
|
80 | - break; |
|
81 | - case (($ordinalValue & 0xF8) == 0xF0): |
|
82 | - // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
83 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
84 | - $ret += 4; |
|
85 | - break; |
|
86 | - case (($ordinalValue & 0xFC) == 0xF8): |
|
87 | - // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
88 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
89 | - $ret += 5; |
|
90 | - break; |
|
91 | - case (($ordinalValue & 0xFE) == 0xFC): |
|
92 | - // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
93 | - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
94 | - $ret += 6; |
|
95 | - break; |
|
96 | - default: |
|
97 | - $ret ++; |
|
98 | - } |
|
99 | - } |
|
100 | - return $ret; |
|
62 | + $strlenVar = strlen($str); |
|
63 | + $d = $ret = 0; |
|
64 | + for ($count = 0; $count < $strlenVar; ++ $count) { |
|
65 | + $ordinalValue = ord($str{$ret}); |
|
66 | + switch (true) { |
|
67 | + case (($ordinalValue >= 0x20) && ($ordinalValue <= 0x7F)): |
|
68 | + // characters U-00000000 - U-0000007F (same as ASCII) |
|
69 | + $ret ++; |
|
70 | + break; |
|
71 | + case (($ordinalValue & 0xE0) == 0xC0): |
|
72 | + // characters U-00000080 - U-000007FF, mask 110XXXXX |
|
73 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
74 | + $ret += 2; |
|
75 | + break; |
|
76 | + case (($ordinalValue & 0xF0) == 0xE0): |
|
77 | + // characters U-00000800 - U-0000FFFF, mask 1110XXXX |
|
78 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
79 | + $ret += 3; |
|
80 | + break; |
|
81 | + case (($ordinalValue & 0xF8) == 0xF0): |
|
82 | + // characters U-00010000 - U-001FFFFF, mask 11110XXX |
|
83 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
84 | + $ret += 4; |
|
85 | + break; |
|
86 | + case (($ordinalValue & 0xFC) == 0xF8): |
|
87 | + // characters U-00200000 - U-03FFFFFF, mask 111110XX |
|
88 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
89 | + $ret += 5; |
|
90 | + break; |
|
91 | + case (($ordinalValue & 0xFE) == 0xFC): |
|
92 | + // characters U-04000000 - U-7FFFFFFF, mask 1111110X |
|
93 | + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 |
|
94 | + $ret += 6; |
|
95 | + break; |
|
96 | + default: |
|
97 | + $ret ++; |
|
98 | + } |
|
99 | + } |
|
100 | + return $ret; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function normalize($arr) |
109 | 109 | { |
110 | - if (!is_array($arr)) { |
|
111 | - return array(); |
|
112 | - } |
|
110 | + if (!is_array($arr)) { |
|
111 | + return array(); |
|
112 | + } |
|
113 | 113 | |
114 | - $normalized = array(); |
|
115 | - foreach ($arr as $key => $val) { |
|
116 | - $normalized[strtolower($key)] = $val; |
|
117 | - } |
|
118 | - return $normalized; |
|
114 | + $normalized = array(); |
|
115 | + foreach ($arr as $key => $val) { |
|
116 | + $normalized[strtolower($key)] = $val; |
|
117 | + } |
|
118 | + return $normalized; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public static function camelCase($value) |
127 | 127 | { |
128 | - $value = ucwords(str_replace(array('-', '_'), ' ', $value)); |
|
129 | - $value = str_replace(' ', '', $value); |
|
130 | - $value[0] = strtolower($value[0]); |
|
131 | - return $value; |
|
128 | + $value = ucwords(str_replace(array('-', '_'), ' ', $value)); |
|
129 | + $value = str_replace(' ', '', $value); |
|
130 | + $value[0] = strtolower($value[0]); |
|
131 | + return $value; |
|
132 | 132 | } |
133 | 133 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | switch (true) { |
67 | 67 | case (($ordinalValue >= 0x20) && ($ordinalValue <= 0x7F)): |
68 | 68 | // characters U-00000000 - U-0000007F (same as ASCII) |
69 | - $ret ++; |
|
69 | + $ret++; |
|
70 | 70 | break; |
71 | 71 | case (($ordinalValue & 0xE0) == 0xC0): |
72 | 72 | // characters U-00000080 - U-000007FF, mask 110XXXXX |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $ret += 6; |
95 | 95 | break; |
96 | 96 | default: |
97 | - $ret ++; |
|
97 | + $ret++; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | return $ret; |
@@ -15,87 +15,87 @@ |
||
15 | 15 | |
16 | 16 | public function rewind() |
17 | 17 | { |
18 | - if (isset($this->modelData[$this->collection_key]) |
|
19 | - && is_array($this->modelData[$this->collection_key])) { |
|
20 | - reset($this->modelData[$this->collection_key]); |
|
21 | - } |
|
18 | + if (isset($this->modelData[$this->collection_key]) |
|
19 | + && is_array($this->modelData[$this->collection_key])) { |
|
20 | + reset($this->modelData[$this->collection_key]); |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function current() |
25 | 25 | { |
26 | - $this->coerceType($this->key()); |
|
27 | - if (is_array($this->modelData[$this->collection_key])) { |
|
28 | - return current($this->modelData[$this->collection_key]); |
|
29 | - } |
|
26 | + $this->coerceType($this->key()); |
|
27 | + if (is_array($this->modelData[$this->collection_key])) { |
|
28 | + return current($this->modelData[$this->collection_key]); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function key() |
33 | 33 | { |
34 | - if (isset($this->modelData[$this->collection_key]) |
|
35 | - && is_array($this->modelData[$this->collection_key])) { |
|
36 | - return key($this->modelData[$this->collection_key]); |
|
37 | - } |
|
34 | + if (isset($this->modelData[$this->collection_key]) |
|
35 | + && is_array($this->modelData[$this->collection_key])) { |
|
36 | + return key($this->modelData[$this->collection_key]); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public function next() |
41 | 41 | { |
42 | - return next($this->modelData[$this->collection_key]); |
|
42 | + return next($this->modelData[$this->collection_key]); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function valid() |
46 | 46 | { |
47 | - $key = $this->key(); |
|
48 | - return $key !== null && $key !== false; |
|
47 | + $key = $this->key(); |
|
48 | + return $key !== null && $key !== false; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | public function count() |
52 | 52 | { |
53 | - if (!isset($this->modelData[$this->collection_key])) { |
|
54 | - return 0; |
|
55 | - } |
|
56 | - return count($this->modelData[$this->collection_key]); |
|
53 | + if (!isset($this->modelData[$this->collection_key])) { |
|
54 | + return 0; |
|
55 | + } |
|
56 | + return count($this->modelData[$this->collection_key]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public function offsetExists($offset) |
60 | 60 | { |
61 | - if (!is_numeric($offset)) { |
|
62 | - return parent::offsetExists($offset); |
|
63 | - } |
|
64 | - return isset($this->modelData[$this->collection_key][$offset]); |
|
61 | + if (!is_numeric($offset)) { |
|
62 | + return parent::offsetExists($offset); |
|
63 | + } |
|
64 | + return isset($this->modelData[$this->collection_key][$offset]); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function offsetGet($offset) |
68 | 68 | { |
69 | - if (!is_numeric($offset)) { |
|
70 | - return parent::offsetGet($offset); |
|
71 | - } |
|
72 | - $this->coerceType($offset); |
|
73 | - return $this->modelData[$this->collection_key][$offset]; |
|
69 | + if (!is_numeric($offset)) { |
|
70 | + return parent::offsetGet($offset); |
|
71 | + } |
|
72 | + $this->coerceType($offset); |
|
73 | + return $this->modelData[$this->collection_key][$offset]; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function offsetSet($offset, $value) |
77 | 77 | { |
78 | - if (!is_numeric($offset)) { |
|
79 | - return parent::offsetSet($offset, $value); |
|
80 | - } |
|
81 | - $this->modelData[$this->collection_key][$offset] = $value; |
|
78 | + if (!is_numeric($offset)) { |
|
79 | + return parent::offsetSet($offset, $value); |
|
80 | + } |
|
81 | + $this->modelData[$this->collection_key][$offset] = $value; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function offsetUnset($offset) |
85 | 85 | { |
86 | - if (!is_numeric($offset)) { |
|
87 | - return parent::offsetUnset($offset); |
|
88 | - } |
|
89 | - unset($this->modelData[$this->collection_key][$offset]); |
|
86 | + if (!is_numeric($offset)) { |
|
87 | + return parent::offsetUnset($offset); |
|
88 | + } |
|
89 | + unset($this->modelData[$this->collection_key][$offset]); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | private function coerceType($offset) |
93 | 93 | { |
94 | - $typeKey = $this->keyType($this->collection_key); |
|
95 | - if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) { |
|
96 | - $type = $this->$typeKey; |
|
97 | - $this->modelData[$this->collection_key][$offset] = |
|
98 | - new $type($this->modelData[$this->collection_key][$offset]); |
|
99 | - } |
|
94 | + $typeKey = $this->keyType($this->collection_key); |
|
95 | + if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) { |
|
96 | + $type = $this->$typeKey; |
|
97 | + $this->modelData[$this->collection_key][$offset] = |
|
98 | + new $type($this->modelData[$this->collection_key][$offset]); |
|
99 | + } |
|
100 | 100 | } |
101 | 101 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!class_exists('Google_Client')) { |
4 | - require_once dirname(__FILE__) . '/autoload.php'; |
|
4 | + require_once dirname(__FILE__).'/autoload.php'; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct($pem) |
40 | 40 | { |
41 | - if (!function_exists('openssl_x509_read')) { |
|
42 | - throw new Google_Exception('Google API PHP client needs the openssl PHP extension'); |
|
43 | - } |
|
44 | - $this->publicKey = openssl_x509_read($pem); |
|
45 | - if (!$this->publicKey) { |
|
46 | - throw new Google_Auth_Exception("Unable to parse PEM: $pem"); |
|
47 | - } |
|
41 | + if (!function_exists('openssl_x509_read')) { |
|
42 | + throw new Google_Exception('Google API PHP client needs the openssl PHP extension'); |
|
43 | + } |
|
44 | + $this->publicKey = openssl_x509_read($pem); |
|
45 | + if (!$this->publicKey) { |
|
46 | + throw new Google_Auth_Exception("Unable to parse PEM: $pem"); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function __destruct() |
51 | 51 | { |
52 | - if ($this->publicKey) { |
|
53 | - openssl_x509_free($this->publicKey); |
|
54 | - } |
|
52 | + if ($this->publicKey) { |
|
53 | + openssl_x509_free($this->publicKey); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function verify($data, $signature) |
67 | 67 | { |
68 | - $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; |
|
69 | - $status = openssl_verify($data, $signature, $this->publicKey, $hash); |
|
70 | - if ($status === -1) { |
|
71 | - throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string()); |
|
72 | - } |
|
73 | - return $status === 1; |
|
68 | + $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; |
|
69 | + $status = openssl_verify($data, $signature, $this->publicKey, $hash); |
|
70 | + if ($status === -1) { |
|
71 | + throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string()); |
|
72 | + } |
|
73 | + return $status === 1; |
|
74 | 74 | } |
75 | 75 | } |
@@ -16,7 +16,7 @@ discard block |
||
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 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256"; |
69 | 69 | $status = openssl_verify($data, $signature, $this->publicKey, $hash); |
70 | 70 | if ($status === -1) { |
71 | - throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string()); |
|
71 | + throw new Google_Auth_Exception('Signature verification error: '.openssl_error_string()); |
|
72 | 72 | } |
73 | 73 | return $status === 1; |
74 | 74 | } |
@@ -74,32 +74,32 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function __construct($config = null) |
76 | 76 | { |
77 | - if (is_string($config) && strlen($config)) { |
|
78 | - $config = new Google_Config($config); |
|
79 | - } else if ( !($config instanceof Google_Config)) { |
|
80 | - $config = new Google_Config(); |
|
77 | + if (is_string($config) && strlen($config)) { |
|
78 | + $config = new Google_Config($config); |
|
79 | + } else if ( !($config instanceof Google_Config)) { |
|
80 | + $config = new Google_Config(); |
|
81 | 81 | |
82 | - if ($this->isAppEngine()) { |
|
83 | - // Automatically use Memcache if we're in AppEngine. |
|
84 | - $config->setCacheClass('Google_Cache_Memcache'); |
|
85 | - } |
|
82 | + if ($this->isAppEngine()) { |
|
83 | + // Automatically use Memcache if we're in AppEngine. |
|
84 | + $config->setCacheClass('Google_Cache_Memcache'); |
|
85 | + } |
|
86 | 86 | |
87 | - if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) { |
|
88 | - // Automatically disable compress.zlib, as currently unsupported. |
|
89 | - $config->setClassConfig('Google_Http_Request', 'disable_gzip', true); |
|
90 | - } |
|
91 | - } |
|
87 | + if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) { |
|
88 | + // Automatically disable compress.zlib, as currently unsupported. |
|
89 | + $config->setClassConfig('Google_Http_Request', 'disable_gzip', true); |
|
90 | + } |
|
91 | + } |
|
92 | 92 | |
93 | - if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) { |
|
94 | - if (function_exists('curl_version') && function_exists('curl_exec') |
|
95 | - && !$this->isAppEngine()) { |
|
96 | - $config->setIoClass("Google_IO_Curl"); |
|
97 | - } else { |
|
98 | - $config->setIoClass("Google_IO_Stream"); |
|
99 | - } |
|
100 | - } |
|
93 | + if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) { |
|
94 | + if (function_exists('curl_version') && function_exists('curl_exec') |
|
95 | + && !$this->isAppEngine()) { |
|
96 | + $config->setIoClass("Google_IO_Curl"); |
|
97 | + } else { |
|
98 | + $config->setIoClass("Google_IO_Stream"); |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - $this->config = $config; |
|
102 | + $this->config = $config; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function getLibraryVersion() |
111 | 111 | { |
112 | - return self::LIBVER; |
|
112 | + return self::LIBVER; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function authenticate($code, $crossClient = false) |
126 | 126 | { |
127 | - $this->authenticated = true; |
|
128 | - return $this->getAuth()->authenticate($code, $crossClient); |
|
127 | + $this->authenticated = true; |
|
128 | + return $this->getAuth()->authenticate($code, $crossClient); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -141,18 +141,18 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function loadServiceAccountJson($jsonLocation, $scopes) |
143 | 143 | { |
144 | - $data = json_decode(file_get_contents($jsonLocation)); |
|
145 | - if (isset($data->type) && $data->type == 'service_account') { |
|
146 | - // Service Account format. |
|
147 | - $cred = new Google_Auth_AssertionCredentials( |
|
148 | - $data->client_email, |
|
149 | - $scopes, |
|
150 | - $data->private_key |
|
151 | - ); |
|
152 | - return $cred; |
|
153 | - } else { |
|
154 | - throw new Google_Exception("Invalid service account JSON file."); |
|
155 | - } |
|
144 | + $data = json_decode(file_get_contents($jsonLocation)); |
|
145 | + if (isset($data->type) && $data->type == 'service_account') { |
|
146 | + // Service Account format. |
|
147 | + $cred = new Google_Auth_AssertionCredentials( |
|
148 | + $data->client_email, |
|
149 | + $scopes, |
|
150 | + $data->private_key |
|
151 | + ); |
|
152 | + return $cred; |
|
153 | + } else { |
|
154 | + throw new Google_Exception("Invalid service account JSON file."); |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function setAuthConfig($json) |
167 | 167 | { |
168 | - $data = json_decode($json); |
|
169 | - $key = isset($data->installed) ? 'installed' : 'web'; |
|
170 | - if (!isset($data->$key)) { |
|
171 | - throw new Google_Exception("Invalid client secret JSON file."); |
|
172 | - } |
|
173 | - $this->setClientId($data->$key->client_id); |
|
174 | - $this->setClientSecret($data->$key->client_secret); |
|
175 | - if (isset($data->$key->redirect_uris)) { |
|
176 | - $this->setRedirectUri($data->$key->redirect_uris[0]); |
|
177 | - } |
|
168 | + $data = json_decode($json); |
|
169 | + $key = isset($data->installed) ? 'installed' : 'web'; |
|
170 | + if (!isset($data->$key)) { |
|
171 | + throw new Google_Exception("Invalid client secret JSON file."); |
|
172 | + } |
|
173 | + $this->setClientId($data->$key->client_id); |
|
174 | + $this->setClientSecret($data->$key->client_secret); |
|
175 | + if (isset($data->$key->redirect_uris)) { |
|
176 | + $this->setRedirectUri($data->$key->redirect_uris[0]); |
|
177 | + } |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function setAuthConfigFile($file) |
188 | 188 | { |
189 | - $this->setAuthConfig(file_get_contents($file)); |
|
189 | + $this->setAuthConfig(file_get_contents($file)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function prepareScopes() |
198 | 198 | { |
199 | - if (empty($this->requestedScopes)) { |
|
200 | - throw new Google_Auth_Exception("No scopes specified"); |
|
201 | - } |
|
202 | - $scopes = implode(' ', $this->requestedScopes); |
|
203 | - return $scopes; |
|
199 | + if (empty($this->requestedScopes)) { |
|
200 | + throw new Google_Auth_Exception("No scopes specified"); |
|
201 | + } |
|
202 | + $scopes = implode(' ', $this->requestedScopes); |
|
203 | + return $scopes; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function setAccessToken($accessToken) |
214 | 214 | { |
215 | - if ($accessToken == 'null') { |
|
216 | - $accessToken = null; |
|
217 | - } |
|
218 | - $this->getAuth()->setAccessToken($accessToken); |
|
215 | + if ($accessToken == 'null') { |
|
216 | + $accessToken = null; |
|
217 | + } |
|
218 | + $this->getAuth()->setAccessToken($accessToken); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function setAuth(Google_Auth_Abstract $auth) |
228 | 228 | { |
229 | - $this->config->setAuthClass(get_class($auth)); |
|
230 | - $this->auth = $auth; |
|
229 | + $this->config->setAuthClass(get_class($auth)); |
|
230 | + $this->auth = $auth; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function setIo(Google_IO_Abstract $io) |
238 | 238 | { |
239 | - $this->config->setIoClass(get_class($io)); |
|
240 | - $this->io = $io; |
|
239 | + $this->config->setIoClass(get_class($io)); |
|
240 | + $this->io = $io; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function setCache(Google_Cache_Abstract $cache) |
248 | 248 | { |
249 | - $this->config->setCacheClass(get_class($cache)); |
|
250 | - $this->cache = $cache; |
|
249 | + $this->config->setCacheClass(get_class($cache)); |
|
250 | + $this->cache = $cache; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function setLogger(Google_Logger_Abstract $logger) |
258 | 258 | { |
259 | - $this->config->setLoggerClass(get_class($logger)); |
|
260 | - $this->logger = $logger; |
|
259 | + $this->config->setLoggerClass(get_class($logger)); |
|
260 | + $this->logger = $logger; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function createAuthUrl() |
268 | 268 | { |
269 | - $scopes = $this->prepareScopes(); |
|
270 | - return $this->getAuth()->createAuthUrl($scopes); |
|
269 | + $scopes = $this->prepareScopes(); |
|
270 | + return $this->getAuth()->createAuthUrl($scopes); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getAccessToken() |
280 | 280 | { |
281 | - $token = $this->getAuth()->getAccessToken(); |
|
282 | - // The response is json encoded, so could be the string null. |
|
283 | - // It is arguable whether this check should be here or lower |
|
284 | - // in the library. |
|
285 | - return (null == $token || 'null' == $token || '[]' == $token) ? null : $token; |
|
281 | + $token = $this->getAuth()->getAccessToken(); |
|
282 | + // The response is json encoded, so could be the string null. |
|
283 | + // It is arguable whether this check should be here or lower |
|
284 | + // in the library. |
|
285 | + return (null == $token || 'null' == $token || '[]' == $token) ? null : $token; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function getRefreshToken() |
293 | 293 | { |
294 | - return $this->getAuth()->getRefreshToken(); |
|
294 | + return $this->getAuth()->getRefreshToken(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function isAccessTokenExpired() |
302 | 302 | { |
303 | - return $this->getAuth()->isAccessTokenExpired(); |
|
303 | + return $this->getAuth()->isAccessTokenExpired(); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function setState($state) |
312 | 312 | { |
313 | - $this->getAuth()->setState($state); |
|
313 | + $this->getAuth()->setState($state); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function setAccessType($accessType) |
322 | 322 | { |
323 | - $this->config->setAccessType($accessType); |
|
323 | + $this->config->setAccessType($accessType); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function setApprovalPrompt($approvalPrompt) |
332 | 332 | { |
333 | - $this->config->setApprovalPrompt($approvalPrompt); |
|
333 | + $this->config->setApprovalPrompt($approvalPrompt); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function setLoginHint($loginHint) |
341 | 341 | { |
342 | - $this->config->setLoginHint($loginHint); |
|
342 | + $this->config->setLoginHint($loginHint); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | public function setApplicationName($applicationName) |
350 | 350 | { |
351 | - $this->config->setApplicationName($applicationName); |
|
351 | + $this->config->setApplicationName($applicationName); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | */ |
358 | 358 | public function setClientId($clientId) |
359 | 359 | { |
360 | - $this->config->setClientId($clientId); |
|
360 | + $this->config->setClientId($clientId); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setClientSecret($clientSecret) |
368 | 368 | { |
369 | - $this->config->setClientSecret($clientSecret); |
|
369 | + $this->config->setClientSecret($clientSecret); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | */ |
376 | 376 | public function setRedirectUri($redirectUri) |
377 | 377 | { |
378 | - $this->config->setRedirectUri($redirectUri); |
|
378 | + $this->config->setRedirectUri($redirectUri); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | */ |
389 | 389 | public function setRequestVisibleActions($requestVisibleActions) |
390 | 390 | { |
391 | - if (is_array($requestVisibleActions)) { |
|
392 | - $requestVisibleActions = join(" ", $requestVisibleActions); |
|
393 | - } |
|
394 | - $this->config->setRequestVisibleActions($requestVisibleActions); |
|
391 | + if (is_array($requestVisibleActions)) { |
|
392 | + $requestVisibleActions = join(" ", $requestVisibleActions); |
|
393 | + } |
|
394 | + $this->config->setRequestVisibleActions($requestVisibleActions); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function setDeveloperKey($developerKey) |
403 | 403 | { |
404 | - $this->config->setDeveloperKey($developerKey); |
|
404 | + $this->config->setDeveloperKey($developerKey); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public function setHostedDomain($hd) |
414 | 414 | { |
415 | - $this->config->setHostedDomain($hd); |
|
415 | + $this->config->setHostedDomain($hd); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function setPrompt($prompt) |
425 | 425 | { |
426 | - $this->config->setPrompt($prompt); |
|
426 | + $this->config->setPrompt($prompt); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function setOpenidRealm($realm) |
436 | 436 | { |
437 | - $this->config->setOpenidRealm($realm); |
|
437 | + $this->config->setOpenidRealm($realm); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function setIncludeGrantedScopes($include) |
447 | 447 | { |
448 | - $this->config->setIncludeGrantedScopes($include); |
|
448 | + $this->config->setIncludeGrantedScopes($include); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function refreshToken($refreshToken) |
456 | 456 | { |
457 | - $this->getAuth()->refreshToken($refreshToken); |
|
457 | + $this->getAuth()->refreshToken($refreshToken); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public function revokeToken($token = null) |
468 | 468 | { |
469 | - return $this->getAuth()->revokeToken($token); |
|
469 | + return $this->getAuth()->revokeToken($token); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | public function verifyIdToken($token = null) |
481 | 481 | { |
482 | - return $this->getAuth()->verifyIdToken($token); |
|
482 | + return $this->getAuth()->verifyIdToken($token); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function verifySignedJwt($id_token, $cert_location, $audience, $issuer, $max_expiry = null) |
496 | 496 | { |
497 | - $auth = new Google_Auth_OAuth2($this); |
|
498 | - $certs = $auth->retrieveCertsFromLocation($cert_location); |
|
499 | - return $auth->verifySignedJwtWithCerts($id_token, $certs, $audience, $issuer, $max_expiry); |
|
497 | + $auth = new Google_Auth_OAuth2($this); |
|
498 | + $certs = $auth->retrieveCertsFromLocation($cert_location); |
|
499 | + return $auth->verifySignedJwtWithCerts($id_token, $certs, $audience, $issuer, $max_expiry); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function setAssertionCredentials(Google_Auth_AssertionCredentials $creds) |
506 | 506 | { |
507 | - $this->getAuth()->setAssertionCredentials($creds); |
|
507 | + $this->getAuth()->setAssertionCredentials($creds); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function setScopes($scopes) |
517 | 517 | { |
518 | - $this->requestedScopes = array(); |
|
519 | - $this->addScope($scopes); |
|
518 | + $this->requestedScopes = array(); |
|
519 | + $this->addScope($scopes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -528,13 +528,13 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function addScope($scope_or_scopes) |
530 | 530 | { |
531 | - if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) { |
|
532 | - $this->requestedScopes[] = $scope_or_scopes; |
|
533 | - } else if (is_array($scope_or_scopes)) { |
|
534 | - foreach ($scope_or_scopes as $scope) { |
|
535 | - $this->addScope($scope); |
|
536 | - } |
|
537 | - } |
|
531 | + if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) { |
|
532 | + $this->requestedScopes[] = $scope_or_scopes; |
|
533 | + } else if (is_array($scope_or_scopes)) { |
|
534 | + foreach ($scope_or_scopes as $scope) { |
|
535 | + $this->addScope($scope); |
|
536 | + } |
|
537 | + } |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | /** |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public function getScopes() |
546 | 546 | { |
547 | - return $this->requestedScopes; |
|
547 | + return $this->requestedScopes; |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | */ |
557 | 557 | public function setUseBatch($useBatch) |
558 | 558 | { |
559 | - // This is actually an alias for setDefer. |
|
560 | - $this->setDefer($useBatch); |
|
559 | + // This is actually an alias for setDefer. |
|
560 | + $this->setDefer($useBatch); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | */ |
569 | 569 | public function setDefer($defer) |
570 | 570 | { |
571 | - $this->deferExecution = $defer; |
|
571 | + $this->deferExecution = $defer; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -580,22 +580,22 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function execute($request) |
582 | 582 | { |
583 | - if ($request instanceof Google_Http_Request) { |
|
584 | - $request->setUserAgent( |
|
585 | - $this->getApplicationName() |
|
586 | - . " " . self::USER_AGENT_SUFFIX |
|
587 | - . $this->getLibraryVersion() |
|
588 | - ); |
|
589 | - if (!$this->getClassConfig("Google_Http_Request", "disable_gzip")) { |
|
590 | - $request->enableGzip(); |
|
591 | - } |
|
592 | - $request->maybeMoveParametersToBody(); |
|
593 | - return Google_Http_REST::execute($this, $request); |
|
594 | - } else if ($request instanceof Google_Http_Batch) { |
|
595 | - return $request->execute(); |
|
596 | - } else { |
|
597 | - throw new Google_Exception("Do not know how to execute this type of object."); |
|
598 | - } |
|
583 | + if ($request instanceof Google_Http_Request) { |
|
584 | + $request->setUserAgent( |
|
585 | + $this->getApplicationName() |
|
586 | + . " " . self::USER_AGENT_SUFFIX |
|
587 | + . $this->getLibraryVersion() |
|
588 | + ); |
|
589 | + if (!$this->getClassConfig("Google_Http_Request", "disable_gzip")) { |
|
590 | + $request->enableGzip(); |
|
591 | + } |
|
592 | + $request->maybeMoveParametersToBody(); |
|
593 | + return Google_Http_REST::execute($this, $request); |
|
594 | + } else if ($request instanceof Google_Http_Batch) { |
|
595 | + return $request->execute(); |
|
596 | + } else { |
|
597 | + throw new Google_Exception("Do not know how to execute this type of object."); |
|
598 | + } |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | */ |
605 | 605 | public function shouldDefer() |
606 | 606 | { |
607 | - return $this->deferExecution; |
|
607 | + return $this->deferExecution; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -612,11 +612,11 @@ discard block |
||
612 | 612 | */ |
613 | 613 | public function getAuth() |
614 | 614 | { |
615 | - if (!isset($this->auth)) { |
|
616 | - $class = $this->config->getAuthClass(); |
|
617 | - $this->auth = new $class($this); |
|
618 | - } |
|
619 | - return $this->auth; |
|
615 | + if (!isset($this->auth)) { |
|
616 | + $class = $this->config->getAuthClass(); |
|
617 | + $this->auth = new $class($this); |
|
618 | + } |
|
619 | + return $this->auth; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function getIo() |
626 | 626 | { |
627 | - if (!isset($this->io)) { |
|
628 | - $class = $this->config->getIoClass(); |
|
629 | - $this->io = new $class($this); |
|
630 | - } |
|
631 | - return $this->io; |
|
627 | + if (!isset($this->io)) { |
|
628 | + $class = $this->config->getIoClass(); |
|
629 | + $this->io = new $class($this); |
|
630 | + } |
|
631 | + return $this->io; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
@@ -636,11 +636,11 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function getCache() |
638 | 638 | { |
639 | - if (!isset($this->cache)) { |
|
640 | - $class = $this->config->getCacheClass(); |
|
641 | - $this->cache = new $class($this); |
|
642 | - } |
|
643 | - return $this->cache; |
|
639 | + if (!isset($this->cache)) { |
|
640 | + $class = $this->config->getCacheClass(); |
|
641 | + $this->cache = new $class($this); |
|
642 | + } |
|
643 | + return $this->cache; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -648,11 +648,11 @@ discard block |
||
648 | 648 | */ |
649 | 649 | public function getLogger() |
650 | 650 | { |
651 | - if (!isset($this->logger)) { |
|
652 | - $class = $this->config->getLoggerClass(); |
|
653 | - $this->logger = new $class($this); |
|
654 | - } |
|
655 | - return $this->logger; |
|
651 | + if (!isset($this->logger)) { |
|
652 | + $class = $this->config->getLoggerClass(); |
|
653 | + $this->logger = new $class($this); |
|
654 | + } |
|
655 | + return $this->logger; |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -663,10 +663,10 @@ discard block |
||
663 | 663 | */ |
664 | 664 | public function getClassConfig($class, $key = null) |
665 | 665 | { |
666 | - if (!is_string($class)) { |
|
667 | - $class = get_class($class); |
|
668 | - } |
|
669 | - return $this->config->getClassConfig($class, $key); |
|
666 | + if (!is_string($class)) { |
|
667 | + $class = get_class($class); |
|
668 | + } |
|
669 | + return $this->config->getClassConfig($class, $key); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -680,10 +680,10 @@ discard block |
||
680 | 680 | */ |
681 | 681 | public function setClassConfig($class, $config, $value = null) |
682 | 682 | { |
683 | - if (!is_string($class)) { |
|
684 | - $class = get_class($class); |
|
685 | - } |
|
686 | - $this->config->setClassConfig($class, $config, $value); |
|
683 | + if (!is_string($class)) { |
|
684 | + $class = get_class($class); |
|
685 | + } |
|
686 | + $this->config->setClassConfig($class, $config, $value); |
|
687 | 687 | |
688 | 688 | } |
689 | 689 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | */ |
693 | 693 | public function getBasePath() |
694 | 694 | { |
695 | - return $this->config->getBasePath(); |
|
695 | + return $this->config->getBasePath(); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | public function getApplicationName() |
702 | 702 | { |
703 | - return $this->config->getApplicationName(); |
|
703 | + return $this->config->getApplicationName(); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function isAppEngine() |
711 | 711 | { |
712 | - return (isset($_SERVER['SERVER_SOFTWARE']) && |
|
713 | - strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false); |
|
712 | + return (isset($_SERVER['SERVER_SOFTWARE']) && |
|
713 | + strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false); |
|
714 | 714 | } |
715 | 715 | } |
@@ -16,7 +16,7 @@ discard block |
||
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 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | if (is_string($config) && strlen($config)) { |
78 | 78 | $config = new Google_Config($config); |
79 | - } else if ( !($config instanceof Google_Config)) { |
|
79 | + } else if (!($config instanceof Google_Config)) { |
|
80 | 80 | $config = new Google_Config(); |
81 | 81 | |
82 | 82 | if ($this->isAppEngine()) { |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | if ($request instanceof Google_Http_Request) { |
584 | 584 | $request->setUserAgent( |
585 | 585 | $this->getApplicationName() |
586 | - . " " . self::USER_AGENT_SUFFIX |
|
586 | + . " ".self::USER_AGENT_SUFFIX |
|
587 | 587 | . $this->getLibraryVersion() |
588 | 588 | ); |
589 | 589 | if (!$this->getClassConfig("Google_Http_Request", "disable_gzip")) { |
@@ -36,44 +36,44 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct(Google_Client $client) |
38 | 38 | { |
39 | - if (! function_exists('apc_add') ) { |
|
40 | - $error = "Apc functions not available"; |
|
39 | + if (! function_exists('apc_add') ) { |
|
40 | + $error = "Apc functions not available"; |
|
41 | 41 | |
42 | - $client->getLogger()->error($error); |
|
43 | - throw new Google_Cache_Exception($error); |
|
44 | - } |
|
42 | + $client->getLogger()->error($error); |
|
43 | + throw new Google_Cache_Exception($error); |
|
44 | + } |
|
45 | 45 | |
46 | - $this->client = $client; |
|
46 | + $this->client = $client; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | - * @inheritDoc |
|
51 | - */ |
|
50 | + * @inheritDoc |
|
51 | + */ |
|
52 | 52 | public function get($key, $expiration = false) |
53 | 53 | { |
54 | - $ret = apc_fetch($key); |
|
55 | - if ($ret === false) { |
|
56 | - $this->client->getLogger()->debug( |
|
57 | - 'APC cache miss', |
|
58 | - array('key' => $key) |
|
59 | - ); |
|
60 | - return false; |
|
61 | - } |
|
62 | - if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { |
|
63 | - $this->client->getLogger()->debug( |
|
64 | - 'APC cache miss (expired)', |
|
65 | - array('key' => $key, 'var' => $ret) |
|
66 | - ); |
|
67 | - $this->delete($key); |
|
68 | - return false; |
|
69 | - } |
|
54 | + $ret = apc_fetch($key); |
|
55 | + if ($ret === false) { |
|
56 | + $this->client->getLogger()->debug( |
|
57 | + 'APC cache miss', |
|
58 | + array('key' => $key) |
|
59 | + ); |
|
60 | + return false; |
|
61 | + } |
|
62 | + if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { |
|
63 | + $this->client->getLogger()->debug( |
|
64 | + 'APC cache miss (expired)', |
|
65 | + array('key' => $key, 'var' => $ret) |
|
66 | + ); |
|
67 | + $this->delete($key); |
|
68 | + return false; |
|
69 | + } |
|
70 | 70 | |
71 | - $this->client->getLogger()->debug( |
|
72 | - 'APC cache hit', |
|
73 | - array('key' => $key, 'var' => $ret) |
|
74 | - ); |
|
71 | + $this->client->getLogger()->debug( |
|
72 | + 'APC cache hit', |
|
73 | + array('key' => $key, 'var' => $ret) |
|
74 | + ); |
|
75 | 75 | |
76 | - return $ret['data']; |
|
76 | + return $ret['data']; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,21 +81,21 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function set($key, $value) |
83 | 83 | { |
84 | - $var = array('time' => time(), 'data' => $value); |
|
85 | - $rc = apc_store($key, $var); |
|
84 | + $var = array('time' => time(), 'data' => $value); |
|
85 | + $rc = apc_store($key, $var); |
|
86 | 86 | |
87 | - if ($rc == false) { |
|
88 | - $this->client->getLogger()->error( |
|
89 | - 'APC cache set failed', |
|
90 | - array('key' => $key, 'var' => $var) |
|
91 | - ); |
|
92 | - throw new Google_Cache_Exception("Couldn't store data"); |
|
93 | - } |
|
87 | + if ($rc == false) { |
|
88 | + $this->client->getLogger()->error( |
|
89 | + 'APC cache set failed', |
|
90 | + array('key' => $key, 'var' => $var) |
|
91 | + ); |
|
92 | + throw new Google_Cache_Exception("Couldn't store data"); |
|
93 | + } |
|
94 | 94 | |
95 | - $this->client->getLogger()->debug( |
|
96 | - 'APC cache set', |
|
97 | - array('key' => $key, 'var' => $var) |
|
98 | - ); |
|
95 | + $this->client->getLogger()->debug( |
|
96 | + 'APC cache set', |
|
97 | + array('key' => $key, 'var' => $var) |
|
98 | + ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function delete($key) |
106 | 106 | { |
107 | - $this->client->getLogger()->debug( |
|
108 | - 'APC cache delete', |
|
109 | - array('key' => $key) |
|
110 | - ); |
|
111 | - apc_delete($key); |
|
107 | + $this->client->getLogger()->debug( |
|
108 | + 'APC cache delete', |
|
109 | + array('key' => $key) |
|
110 | + ); |
|
111 | + apc_delete($key); |
|
112 | 112 | } |
113 | 113 | } |
@@ -16,7 +16,7 @@ discard block |
||
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 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct(Google_Client $client) |
38 | 38 | { |
39 | - if (! function_exists('apc_add') ) { |
|
39 | + if (!function_exists('apc_add')) { |
|
40 | 40 | $error = "Apc functions not available"; |
41 | 41 | |
42 | 42 | $client->getLogger()->error($error); |
@@ -43,29 +43,29 @@ discard block |
||
43 | 43 | |
44 | 44 | public function __construct(Google_Client $client) |
45 | 45 | { |
46 | - if (!function_exists('memcache_connect') && !class_exists("Memcached")) { |
|
47 | - $error = "Memcache functions not available"; |
|
48 | - |
|
49 | - $client->getLogger()->error($error); |
|
50 | - throw new Google_Cache_Exception($error); |
|
51 | - } |
|
52 | - |
|
53 | - $this->client = $client; |
|
54 | - |
|
55 | - if ($client->isAppEngine()) { |
|
56 | - // No credentials needed for GAE. |
|
57 | - $this->mc = new Memcached(); |
|
58 | - $this->connection = true; |
|
59 | - } else { |
|
60 | - $this->host = $client->getClassConfig($this, 'host'); |
|
61 | - $this->port = $client->getClassConfig($this, 'port'); |
|
62 | - if (empty($this->host) || (empty($this->port) && (string) $this->port != "0")) { |
|
63 | - $error = "You need to supply a valid memcache host and port"; |
|
64 | - |
|
65 | - $client->getLogger()->error($error); |
|
66 | - throw new Google_Cache_Exception($error); |
|
67 | - } |
|
68 | - } |
|
46 | + if (!function_exists('memcache_connect') && !class_exists("Memcached")) { |
|
47 | + $error = "Memcache functions not available"; |
|
48 | + |
|
49 | + $client->getLogger()->error($error); |
|
50 | + throw new Google_Cache_Exception($error); |
|
51 | + } |
|
52 | + |
|
53 | + $this->client = $client; |
|
54 | + |
|
55 | + if ($client->isAppEngine()) { |
|
56 | + // No credentials needed for GAE. |
|
57 | + $this->mc = new Memcached(); |
|
58 | + $this->connection = true; |
|
59 | + } else { |
|
60 | + $this->host = $client->getClassConfig($this, 'host'); |
|
61 | + $this->port = $client->getClassConfig($this, 'port'); |
|
62 | + if (empty($this->host) || (empty($this->port) && (string) $this->port != "0")) { |
|
63 | + $error = "You need to supply a valid memcache host and port"; |
|
64 | + |
|
65 | + $client->getLogger()->error($error); |
|
66 | + throw new Google_Cache_Exception($error); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,35 +73,35 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function get($key, $expiration = false) |
75 | 75 | { |
76 | - $this->connect(); |
|
77 | - $ret = false; |
|
78 | - if ($this->mc) { |
|
79 | - $ret = $this->mc->get($key); |
|
80 | - } else { |
|
81 | - $ret = memcache_get($this->connection, $key); |
|
82 | - } |
|
83 | - if ($ret === false) { |
|
84 | - $this->client->getLogger()->debug( |
|
85 | - 'Memcache cache miss', |
|
86 | - array('key' => $key) |
|
87 | - ); |
|
88 | - return false; |
|
89 | - } |
|
90 | - if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { |
|
91 | - $this->client->getLogger()->debug( |
|
92 | - 'Memcache cache miss (expired)', |
|
93 | - array('key' => $key, 'var' => $ret) |
|
94 | - ); |
|
95 | - $this->delete($key); |
|
96 | - return false; |
|
97 | - } |
|
98 | - |
|
99 | - $this->client->getLogger()->debug( |
|
100 | - 'Memcache cache hit', |
|
101 | - array('key' => $key, 'var' => $ret) |
|
102 | - ); |
|
103 | - |
|
104 | - return $ret['data']; |
|
76 | + $this->connect(); |
|
77 | + $ret = false; |
|
78 | + if ($this->mc) { |
|
79 | + $ret = $this->mc->get($key); |
|
80 | + } else { |
|
81 | + $ret = memcache_get($this->connection, $key); |
|
82 | + } |
|
83 | + if ($ret === false) { |
|
84 | + $this->client->getLogger()->debug( |
|
85 | + 'Memcache cache miss', |
|
86 | + array('key' => $key) |
|
87 | + ); |
|
88 | + return false; |
|
89 | + } |
|
90 | + if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) { |
|
91 | + $this->client->getLogger()->debug( |
|
92 | + 'Memcache cache miss (expired)', |
|
93 | + array('key' => $key, 'var' => $ret) |
|
94 | + ); |
|
95 | + $this->delete($key); |
|
96 | + return false; |
|
97 | + } |
|
98 | + |
|
99 | + $this->client->getLogger()->debug( |
|
100 | + 'Memcache cache hit', |
|
101 | + array('key' => $key, 'var' => $ret) |
|
102 | + ); |
|
103 | + |
|
104 | + return $ret['data']; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -112,29 +112,29 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function set($key, $value) |
114 | 114 | { |
115 | - $this->connect(); |
|
116 | - // we store it with the cache_time default expiration so objects will at |
|
117 | - // least get cleaned eventually. |
|
118 | - $data = array('time' => time(), 'data' => $value); |
|
119 | - $rc = false; |
|
120 | - if ($this->mc) { |
|
121 | - $rc = $this->mc->set($key, $data); |
|
122 | - } else { |
|
123 | - $rc = memcache_set($this->connection, $key, $data, false); |
|
124 | - } |
|
125 | - if ($rc == false) { |
|
126 | - $this->client->getLogger()->error( |
|
127 | - 'Memcache cache set failed', |
|
128 | - array('key' => $key, 'var' => $data) |
|
129 | - ); |
|
130 | - |
|
131 | - throw new Google_Cache_Exception("Couldn't store data in cache"); |
|
132 | - } |
|
133 | - |
|
134 | - $this->client->getLogger()->debug( |
|
135 | - 'Memcache cache set', |
|
136 | - array('key' => $key, 'var' => $data) |
|
137 | - ); |
|
115 | + $this->connect(); |
|
116 | + // we store it with the cache_time default expiration so objects will at |
|
117 | + // least get cleaned eventually. |
|
118 | + $data = array('time' => time(), 'data' => $value); |
|
119 | + $rc = false; |
|
120 | + if ($this->mc) { |
|
121 | + $rc = $this->mc->set($key, $data); |
|
122 | + } else { |
|
123 | + $rc = memcache_set($this->connection, $key, $data, false); |
|
124 | + } |
|
125 | + if ($rc == false) { |
|
126 | + $this->client->getLogger()->error( |
|
127 | + 'Memcache cache set failed', |
|
128 | + array('key' => $key, 'var' => $data) |
|
129 | + ); |
|
130 | + |
|
131 | + throw new Google_Cache_Exception("Couldn't store data in cache"); |
|
132 | + } |
|
133 | + |
|
134 | + $this->client->getLogger()->debug( |
|
135 | + 'Memcache cache set', |
|
136 | + array('key' => $key, 'var' => $data) |
|
137 | + ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function delete($key) |
145 | 145 | { |
146 | - $this->connect(); |
|
147 | - if ($this->mc) { |
|
148 | - $this->mc->delete($key, 0); |
|
149 | - } else { |
|
150 | - memcache_delete($this->connection, $key, 0); |
|
151 | - } |
|
152 | - |
|
153 | - $this->client->getLogger()->debug( |
|
154 | - 'Memcache cache delete', |
|
155 | - array('key' => $key) |
|
156 | - ); |
|
146 | + $this->connect(); |
|
147 | + if ($this->mc) { |
|
148 | + $this->mc->delete($key, 0); |
|
149 | + } else { |
|
150 | + memcache_delete($this->connection, $key, 0); |
|
151 | + } |
|
152 | + |
|
153 | + $this->client->getLogger()->debug( |
|
154 | + 'Memcache cache delete', |
|
155 | + array('key' => $key) |
|
156 | + ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,23 +162,23 @@ discard block |
||
162 | 162 | */ |
163 | 163 | private function connect() |
164 | 164 | { |
165 | - if ($this->connection) { |
|
166 | - return; |
|
167 | - } |
|
168 | - |
|
169 | - if (class_exists("Memcached")) { |
|
170 | - $this->mc = new Memcached(); |
|
171 | - $this->mc->addServer($this->host, $this->port); |
|
172 | - $this->connection = true; |
|
173 | - } else { |
|
174 | - $this->connection = memcache_pconnect($this->host, $this->port); |
|
175 | - } |
|
176 | - |
|
177 | - if (! $this->connection) { |
|
178 | - $error = "Couldn't connect to memcache server"; |
|
179 | - |
|
180 | - $this->client->getLogger()->error($error); |
|
181 | - throw new Google_Cache_Exception($error); |
|
182 | - } |
|
165 | + if ($this->connection) { |
|
166 | + return; |
|
167 | + } |
|
168 | + |
|
169 | + if (class_exists("Memcached")) { |
|
170 | + $this->mc = new Memcached(); |
|
171 | + $this->mc->addServer($this->host, $this->port); |
|
172 | + $this->connection = true; |
|
173 | + } else { |
|
174 | + $this->connection = memcache_pconnect($this->host, $this->port); |
|
175 | + } |
|
176 | + |
|
177 | + if (! $this->connection) { |
|
178 | + $error = "Couldn't connect to memcache server"; |
|
179 | + |
|
180 | + $this->client->getLogger()->error($error); |
|
181 | + throw new Google_Cache_Exception($error); |
|
182 | + } |
|
183 | 183 | } |
184 | 184 | } |
@@ -16,7 +16,7 @@ discard block |
||
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 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $this->connection = memcache_pconnect($this->host, $this->port); |
175 | 175 | } |
176 | 176 | |
177 | - if (! $this->connection) { |
|
177 | + if (!$this->connection) { |
|
178 | 178 | $error = "Couldn't connect to memcache server"; |
179 | 179 | |
180 | 180 | $this->client->getLogger()->error($error); |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | - * @inheritDoc |
|
35 | - */ |
|
34 | + * @inheritDoc |
|
35 | + */ |
|
36 | 36 | public function get($key, $expiration = false) |
37 | 37 | { |
38 | - return false; |
|
38 | + return false; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function set($key, $value) |
45 | 45 | { |
46 | - // Nop. |
|
46 | + // Nop. |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,6 +52,6 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function delete($key) |
54 | 54 | { |
55 | - // Nop. |
|
55 | + // Nop. |
|
56 | 56 | } |
57 | 57 | } |
@@ -16,7 +16,7 @@ |
||
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 | /** |