@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @author Stuart Langley <[email protected]> |
22 | 22 | */ |
23 | 23 | |
24 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
24 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
25 | 25 | require_once dirname(__FILE__) . '/../autoload.php'; |
26 | 26 | } |
27 | 27 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function __construct(MonsterInsights_GA_Lib_Client $client) |
39 | 39 | { |
40 | - if (!extension_loaded('curl')) { |
|
40 | + if ( ! extension_loaded('curl')) { |
|
41 | 41 | $error = 'The cURL IO handler requires the cURL extension to be enabled'; |
42 | 42 | $client->getLogger()->critical($error); |
43 | 43 | throw new MonsterInsights_GA_Lib_IO_Exception($error); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | curl_setopt($curl, $key, $var); |
103 | 103 | } |
104 | 104 | |
105 | - if (!isset($this->options[CURLOPT_CAINFO])) { |
|
105 | + if ( ! isset($this->options[CURLOPT_CAINFO])) { |
|
106 | 106 | curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem'); |
107 | 107 | } |
108 | 108 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * Abstract IO base class |
20 | 20 | */ |
21 | 21 | |
22 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
22 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
23 | 23 | require_once dirname(__FILE__) . '/../autoload.php'; |
24 | 24 | } |
25 | 25 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // First, check to see if we have a valid cached version. |
125 | 125 | $cached = $this->getCachedRequest($request); |
126 | 126 | if ($cached !== false && $cached instanceof MonsterInsights_GA_Lib_Http_Request) { |
127 | - if (!$this->checkMustRevalidateCachedRequest($cached, $request)) { |
|
127 | + if ( ! $this->checkMustRevalidateCachedRequest($cached, $request)) { |
|
128 | 128 | return $cached; |
129 | 129 | } |
130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | return $cached; |
142 | 142 | } |
143 | 143 | |
144 | - if (!isset($responseHeaders['Date']) && !isset($responseHeaders['date'])) { |
|
144 | + if ( ! isset($responseHeaders['Date']) && ! isset($responseHeaders['date'])) { |
|
145 | 145 | $responseHeaders['date'] = date("r"); |
146 | 146 | } |
147 | 147 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | // Make sure the content-length header is set. |
196 | - if (!$postBody || is_string($postBody)) { |
|
196 | + if ( ! $postBody || is_string($postBody)) { |
|
197 | 197 | $postsLength = strlen($postBody); |
198 | 198 | $request->setRequestHeaders(array('content-length' => $postsLength)); |
199 | 199 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | protected function updateCachedRequest($cached, $responseHeaders) |
237 | 237 | { |
238 | 238 | $hopByHop = self::$HOP_BY_HOP; |
239 | - if (!empty($responseHeaders['connection'])) { |
|
239 | + if ( ! empty($responseHeaders['connection'])) { |
|
240 | 240 | $connectionHeaders = array_map( |
241 | 241 | 'strtolower', |
242 | 242 | array_filter( |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | // Subtract the proxy header size unless the cURL bug prior to 7.30.0 |
268 | 268 | // is present which prevented the proxy header size from being taken into |
269 | 269 | // account. |
270 | - if (!$this->needsQuirk()) { |
|
270 | + if ( ! $this->needsQuirk()) { |
|
271 | 271 | $headerSize -= strlen($established_header); |
272 | 272 | } |
273 | 273 | break; |
@@ -280,8 +280,7 @@ discard block |
||
280 | 280 | } else { |
281 | 281 | $responseSegments = explode("\r\n\r\n", $respData, 2); |
282 | 282 | $responseHeaders = $responseSegments[0]; |
283 | - $responseBody = isset($responseSegments[1]) ? $responseSegments[1] : |
|
284 | - null; |
|
283 | + $responseBody = isset($responseSegments[1]) ? $responseSegments[1] : null; |
|
285 | 284 | } |
286 | 285 | |
287 | 286 | $responseHeaders = $this->getHttpResponseHeaders($responseHeaders); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | { |
47 | 47 | if (!ini_get('allow_url_fopen')) { |
48 | 48 | $error = 'The stream IO handler requires the allow_url_fopen runtime ' . |
49 | - 'configuration to be enabled'; |
|
49 | + 'configuration to be enabled'; |
|
50 | 50 | $client->getLogger()->critical($error); |
51 | 51 | throw new MonsterInsights_GA_Lib_IO_Exception($error); |
52 | 52 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @author Stuart Langley <[email protected]> |
22 | 22 | */ |
23 | 23 | |
24 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
24 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
25 | 25 | require_once dirname(__FILE__) . '/../autoload.php'; |
26 | 26 | } |
27 | 27 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public function __construct(MonsterInsights_GA_Lib_Client $client) |
46 | 46 | { |
47 | - if (!ini_get('allow_url_fopen')) { |
|
47 | + if ( ! ini_get('allow_url_fopen')) { |
|
48 | 48 | $error = 'The stream IO handler requires the allow_url_fopen runtime ' . |
49 | 49 | 'configuration to be enabled'; |
50 | 50 | $client->getLogger()->critical($error); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $requestSslContext = array_key_exists('ssl', $default_options) ? |
88 | 88 | $default_options['ssl'] : array(); |
89 | 89 | |
90 | - if (!$this->client->isAppEngine() && !array_key_exists("cafile", $requestSslContext)) { |
|
90 | + if ( ! $this->client->isAppEngine() && ! array_key_exists("cafile", $requestSslContext)) { |
|
91 | 91 | $requestSslContext["cafile"] = dirname(__FILE__) . '/cacerts.pem'; |
92 | 92 | } |
93 | 93 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | 17 | |
18 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
18 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
19 | 19 | require_once dirname(__FILE__) . '/../autoload.php'; |
20 | 20 | } |
21 | 21 | |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct($pem) |
40 | 40 | { |
41 | - if (!function_exists('openssl_x509_read')) { |
|
41 | + if ( ! function_exists('openssl_x509_read')) { |
|
42 | 42 | throw new MonsterInsights_GA_Lib_Exception('Google API PHP client needs the openssl PHP extension'); |
43 | 43 | } |
44 | 44 | $this->publicKey = openssl_x509_read($pem); |
45 | - if (!$this->publicKey) { |
|
45 | + if ( ! $this->publicKey) { |
|
46 | 46 | throw new MonsterInsights_GA_Lib_Auth_Exception("Unable to parse PEM: $pem"); |
47 | 47 | } |
48 | 48 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
3 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
4 | 4 | require_once dirname(__FILE__) . '/autoload.php'; |
5 | 5 | } |
6 | 6 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public function count() |
52 | 52 | { |
53 | - if (!isset($this->modelData[$this->collection_key])) { |
|
53 | + if ( ! isset($this->modelData[$this->collection_key])) { |
|
54 | 54 | return 0; |
55 | 55 | } |
56 | 56 | return count($this->modelData[$this->collection_key]); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | public function offsetExists($offset) |
60 | 60 | { |
61 | - if (!is_numeric($offset)) { |
|
61 | + if ( ! is_numeric($offset)) { |
|
62 | 62 | return parent::offsetExists($offset); |
63 | 63 | } |
64 | 64 | return isset($this->modelData[$this->collection_key][$offset]); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function offsetGet($offset) |
68 | 68 | { |
69 | - if (!is_numeric($offset)) { |
|
69 | + if ( ! is_numeric($offset)) { |
|
70 | 70 | return parent::offsetGet($offset); |
71 | 71 | } |
72 | 72 | $this->coerceType($offset); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function offsetSet($offset, $value) |
77 | 77 | { |
78 | - if (!is_numeric($offset)) { |
|
78 | + if ( ! is_numeric($offset)) { |
|
79 | 79 | return parent::offsetSet($offset, $value); |
80 | 80 | } |
81 | 81 | $this->modelData[$this->collection_key][$offset] = $value; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | public function offsetUnset($offset) |
85 | 85 | { |
86 | - if (!is_numeric($offset)) { |
|
86 | + if ( ! is_numeric($offset)) { |
|
87 | 87 | return parent::offsetUnset($offset); |
88 | 88 | } |
89 | 89 | unset($this->modelData[$this->collection_key][$offset]); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | private function coerceType($offset) |
93 | 93 | { |
94 | 94 | $typeKey = $this->keyType($this->collection_key); |
95 | - if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) { |
|
95 | + if (isset($this->$typeKey) && ! is_object($this->modelData[$this->collection_key][$offset])) { |
|
96 | 96 | $type = $this->$typeKey; |
97 | 97 | $this->modelData[$this->collection_key][$offset] = |
98 | 98 | new $type($this->modelData[$this->collection_key][$offset]); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $keyTypeName = $this->keyType($key); |
57 | 57 | $keyDataType = $this->dataType($key); |
58 | - if (isset($this->$keyTypeName) && !isset($this->processed[$key])) { |
|
58 | + if (isset($this->$keyTypeName) && ! isset($this->processed[$key])) { |
|
59 | 59 | if (isset($this->modelData[$key])) { |
60 | 60 | $val = $this->modelData[$key]; |
61 | 61 | } else if (isset($this->$keyDataType) && |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | // Hard initialise simple types, lazy load more complex ones. |
100 | 100 | foreach ($array as $key => $val) { |
101 | - if ( !property_exists($this, $this->keyType($key)) && |
|
101 | + if ( ! property_exists($this, $this->keyType($key)) && |
|
102 | 102 | property_exists($this, $key)) { |
103 | 103 | $this->$key = $val; |
104 | 104 | unset($array[$key]); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function isAssociativeArray($array) |
208 | 208 | { |
209 | - if (!is_array($array)) { |
|
209 | + if ( ! is_array($array)) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | $keys = array_keys($array); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | public function assertIsArray($obj, $method) |
241 | 241 | { |
242 | - if ($obj && !is_array($obj)) { |
|
242 | + if ($obj && ! is_array($obj)) { |
|
243 | 243 | throw new MonsterInsights_GA_Lib_Exception( |
244 | 244 | "Incorrect parameter type passed to $method(). Expected an array." |
245 | 245 | ); |
@@ -254,8 +254,7 @@ discard block |
||
254 | 254 | public function offsetGet($offset) |
255 | 255 | { |
256 | 256 | return isset($this->$offset) ? |
257 | - $this->$offset : |
|
258 | - $this->__get($offset); |
|
257 | + $this->$offset : $this->__get($offset); |
|
259 | 258 | } |
260 | 259 | |
261 | 260 | public function offsetSet($offset, $value) |
@@ -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; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function normalize($arr) |
109 | 109 | { |
110 | - if (!is_array($arr)) { |
|
110 | + if ( ! is_array($arr)) { |
|
111 | 111 | return array(); |
112 | 112 | } |
113 | 113 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | 17 | |
18 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
18 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
19 | 19 | require_once dirname(__FILE__) . '/../autoload.php'; |
20 | 20 | } |
21 | 21 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | if ($token == null) { |
64 | 64 | throw new MonsterInsights_GA_Lib_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 MonsterInsights_GA_Lib_Auth_Exception("Invalid token format"); |
68 | 68 | } |
69 | 69 | $token['created'] = time(); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function isAccessTokenExpired() |
135 | 135 | { |
136 | - if (!$this->token || !isset($this->token['created'])) { |
|
136 | + if ( ! $this->token || ! isset($this->token['created'])) { |
|
137 | 137 | return true; |
138 | 138 | } |
139 | 139 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | 17 | |
18 | -if (!class_exists('MonsterInsights_GA_Lib_Client')) { |
|
18 | +if ( ! class_exists('MonsterInsights_GA_Lib_Client')) { |
|
19 | 19 | require_once dirname(__FILE__) . '/../autoload.php'; |
20 | 20 | } |
21 | 21 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function getCacheKey() |
77 | 77 | { |
78 | - if (!$this->useCache) { |
|
78 | + if ( ! $this->useCache) { |
|
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | $h = $this->sub; |