Passed
Push — main ( 992366...dd7998 )
by Dylan
02:08
created
src/services/Curl.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         }
189 189
 
190 190
         if ($this->_enable_cache && $this->getMethod() === 'GET') {
191
-            $cache_key = urlencode($request_uri) . implode(',', $send_headers);
191
+            $cache_key = urlencode($request_uri).implode(',', $send_headers);
192 192
             if (array_key_exists($cache_key, self::$_cache)) {
193 193
                 return self::$_cache[$cache_key];
194 194
             }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
209 209
 
210 210
         if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
211
-        if (!is_null($post_data))   {
211
+        if (!is_null($post_data)) {
212 212
             curl_setopt($ch, CURLOPT_POST, 1);
213 213
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
214 214
         }
Please login to merge, or discard this patch.
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,9 +39,15 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct(string $url = null, array $data = [], array $headers = [])
41 41
     {
42
-        if (!is_null($url)) $this->setURL($url);
43
-        foreach ($data as $name => $value)      $this->addDataParam($name, $value);
44
-        foreach ($headers as $name => $value)   $this->addHeader($name, $value);
42
+        if (!is_null($url)) {
43
+            $this->setURL($url);
44
+        }
45
+        foreach ($data as $name => $value) {
46
+            $this->addDataParam($name, $value);
47
+        }
48
+        foreach ($headers as $name => $value) {
49
+            $this->addHeader($name, $value);
50
+        }
45 51
     }
46 52
 
47 53
     /**
@@ -98,7 +104,9 @@  discard block
 block discarded – undo
98 104
 
99 105
     public function removeDataParam(string $name): Curl
100 106
     {
101
-        if (array_key_exists($name, $this->_data)) unset($this->_data[$name]);
107
+        if (array_key_exists($name, $this->_data)) {
108
+            unset($this->_data[$name]);
109
+        }
102 110
         return $this;
103 111
     }
104 112
 
@@ -127,7 +135,9 @@  discard block
 block discarded – undo
127 135
      */
128 136
     public function removeHeader(string $name): Curl
129 137
     {
130
-        if (array_key_exists($name, $this->_headers)) unset($this->_headers[$name]);
138
+        if (array_key_exists($name, $this->_headers)) {
139
+            unset($this->_headers[$name]);
140
+        }
131 141
         return $this;
132 142
     }
133 143
 
@@ -171,13 +181,17 @@  discard block
 block discarded – undo
171 181
         $request_uri    = $this->getURL();
172 182
 
173 183
         //  Headers
174
-        foreach ($this->getHeaders() as $k => $v) $send_headers[] = "{$k}: {$v}";
184
+        foreach ($this->getHeaders() as $k => $v) {
185
+            $send_headers[] = "{$k}: {$v}";
186
+        }
175 187
 
176 188
         // Request Data
177 189
         switch ($this->getMethod()) {
178 190
             case 'GET':
179 191
             case 'DELETE':
180
-                foreach ($this->getDataParams() as $name => $value) $request_uri = URL::setGetVar($name, $value, $request_uri);
192
+                foreach ($this->getDataParams() as $name => $value) {
193
+                    $request_uri = URL::setGetVar($name, $value, $request_uri);
194
+                }
181 195
                 break;
182 196
 
183 197
             case 'POST':
@@ -208,7 +222,9 @@  discard block
 block discarded – undo
208 222
         curl_setopt($ch, CURLINFO_HEADER_OUT, true);
209 223
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
210 224
 
211
-        if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
225
+        if (!empty($send_headers)) {
226
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
227
+        }
212 228
         if (!is_null($post_data))   {
213 229
             curl_setopt($ch, CURLOPT_POST, 1);
214 230
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
@@ -218,7 +234,9 @@  discard block
 block discarded – undo
218 234
         $http_code  = curl_getinfo($ch, CURLINFO_HTTP_CODE);
219 235
 
220 236
         $response = new CurlResponse($http_code, $result);
221
-        if ($this->_enable_cache && isset($cache_key)) self::$_cache[$cache_key] = $response;
237
+        if ($this->_enable_cache && isset($cache_key)) {
238
+            self::$_cache[$cache_key] = $response;
239
+        }
222 240
 
223 241
         return $response;
224 242
     }
Please login to merge, or discard this patch.
src/CurlResponse.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@
 block discarded – undo
40 40
     public function getJSON(): ?array
41 41
     {
42 42
         $data = json_decode($this->result, true);
43
-        if (!is_array($data)) return null;
43
+        if (!is_array($data)) {
44
+            return null;
45
+        }
44 46
         
45 47
         return $data;
46 48
     }
Please login to merge, or discard this patch.
src/Client.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,6 +96,6 @@
 block discarded – undo
96 96
      */
97 97
     private function auth_url(string $path): string
98 98
     {
99
-        return $this->_auth_domain . '/' . ltrim($path, '/');
99
+        return $this->_auth_domain.'/'.ltrim($path, '/');
100 100
     }
101 101
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@
 block discarded – undo
67 67
      */
68 68
     public function getSites(string $access_token = ''): array
69 69
     {
70
-        if (!$access_token) $access_token = $this->getAccessToken();
70
+        if (!$access_token) {
71
+            $access_token = $this->getAccessToken();
72
+        }
71 73
 
72 74
         $curl = new Curl($this->auth_url(self::SITES_URL), [
73 75
             'access_token' => $access_token
Please login to merge, or discard this patch.
src/utils/URL.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
     public static function setGetVar(string $key, string $value, string $url): string
21 21
     {
22 22
         if (!self::is_absolute_url($url)) {
23
-            $url = 'http://dummy.com/' . ltrim($url, '/');
23
+            $url = 'http://dummy.com/'.ltrim($url, '/');
24 24
         }
25 25
 
26 26
         // try to parse uri
27 27
         $parts = parse_url($url);
28 28
         if (empty($parts)) {
29
-            throw new InvalidArgumentException("Can't parse URL: " . $url);
29
+            throw new InvalidArgumentException("Can't parse URL: ".$url);
30 30
         }
31 31
 
32 32
         // Parse params and add new variable
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
         // Generate URI segments and formatting
41 41
         $scheme = (array_key_exists('scheme', $parts)) ? $parts['scheme'] : 'http';
42 42
         $user = (array_key_exists('user', $parts)) ? $parts['user'] : '';
43
-        $port = (array_key_exists('port', $parts) && $parts['port']) ? ':' . $parts['port'] : '';
43
+        $port = (array_key_exists('port', $parts) && $parts['port']) ? ':'.$parts['port'] : '';
44 44
 
45 45
         if ($user != '') {
46 46
             // format in either user:[email protected] or [email protected]
47
-            $user .= (array_key_exists('pass', $parts) && $parts['pass']) ? ':' . $parts['pass'] . '@' : '';
47
+            $user .= (array_key_exists('pass', $parts) && $parts['pass']) ? ':'.$parts['pass'].'@' : '';
48 48
         }
49 49
 
50 50
         // handle URL params which are existing / new
51
-        $params = ($params) ? '?' . http_build_query($params) : '';
51
+        $params = ($params) ? '?'.http_build_query($params) : '';
52 52
 
53 53
         // Recompile URI segments
54
-        $newUri = $scheme . '://' . $user . $parts['host'] . $port . $parts['path'] . $params;
54
+        $newUri = $scheme.'://'.$user.$parts['host'].$port.$parts['path'].$params;
55 55
 
56 56
         return str_replace('http://dummy.com/', '', $newUri);
57 57
     }
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     {
65 65
         // Strip off the query and fragment parts of the URL before checking
66 66
         if (($queryPosition = strpos($url, '?')) !== false) {
67
-            $url = substr($url, 0, $queryPosition - 1);
67
+            $url = substr($url, 0, $queryPosition-1);
68 68
         }
69 69
         if (($hashPosition = strpos($url, '#')) !== false) {
70
-            $url = substr($url, 0, $hashPosition - 1);
70
+            $url = substr($url, 0, $hashPosition-1);
71 71
         }
72 72
         $colonPosition = strpos($url, ':');
73 73
         $slashPosition = strpos($url, '/');
Please login to merge, or discard this patch.
src/App.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
84 84
             $promise->reject($response->getRaw());
85
-        } else {
85
+        }else {
86 86
             $promise->resolve($json['access_token']);
87 87
         }
88 88
 
@@ -124,6 +124,6 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function auth_url(string $path): string
126 126
     {
127
-        return $this->_auth_domain . '/' . ltrim($path, '/');
127
+        return $this->_auth_domain.'/'.ltrim($path, '/');
128 128
     }
129 129
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@
 block discarded – undo
44 44
      */
45 45
     public function getAPIChallenge(): string
46 46
     {
47
-        if (!$this->_api_challenge) $this->_api_challenge = Utils::create_random_string(128);
47
+        if (!$this->_api_challenge) {
48
+            $this->_api_challenge = Utils::create_random_string(128);
49
+        }
48 50
         return $this->_api_challenge;
49 51
     }
50 52
 
Please login to merge, or discard this patch.
src/utils/Utils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
         $randomString = '';
18 18
 
19 19
         for ($i = 0; $i < $length; $i++) {
20
-            $randomString .= $characters[rand(0, $charactersLength - 1)];
20
+            $randomString .= $characters[rand(0, $charactersLength-1)];
21 21
         }
22 22
 
23 23
         return $randomString;
@@ -29,6 +29,6 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function pack(string $str): string
31 31
     {
32
-        return rtrim(strtr(base64_encode(pack('H*',  hash('sha256', $str))), '+/', '-_'), '=');
32
+        return rtrim(strtr(base64_encode(pack('H*', hash('sha256', $str))), '+/', '-_'), '=');
33 33
     }
34 34
 }
Please login to merge, or discard this patch.