Completed
Push — master ( 600f6d...f1984f )
by Hector
28s queued 11s
created
autoload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
  * @param string $class The fully-qualified class name.
7 7
  * @return void
8 8
  */
9
-spl_autoload_register(function ($class) {
9
+spl_autoload_register(function($class) {
10 10
 
11 11
     // project-specific namespace prefix
12 12
     $prefix = 'Hborras\\TwitterAdsSDK\\';
13 13
 
14 14
     // base directory for the namespace prefix
15
-    $base_dir = __DIR__ . '/src/';
15
+    $base_dir = __DIR__.'/src/';
16 16
 
17 17
     // does the class use the namespace prefix?
18 18
     $len = strlen($prefix);
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     // replace the namespace prefix with the base directory, replace namespace
28 28
     // separators with directory separators in the relative class name, append
29 29
     // with .php
30
-    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
30
+    $file = $base_dir.str_replace('\\', '/', $relative_class).'.php';
31 31
 
32 32
     // if the file exists, require it
33 33
     if (file_exists($file)) {
Please login to merge, or discard this patch.
src/TONUpload.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -90,6 +90,12 @@
 block discarded – undo
90 90
         return $response;
91 91
     }
92 92
 
93
+    /**
94
+     * @param integer $chunkSize
95
+     * @param string $bytes
96
+     * @param integer $bytesStart
97
+     * @param integer $bytesRead
98
+     */
93 99
     public function uploadChunk($resource, $chunkSize, $bytes, $bytesStart, $bytesRead)
94 100
     {
95 101
         $headers = [
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
     {
82 82
         /** Here you can add any header you want to the request*/
83 83
         $headers = [
84
-            'x-ton-expires: ' . gmdate('D, d M Y H:i:s T', strtotime("+10 day")),
85
-            'content-type: ' . $this->getContentType(),
86
-            'Content-Length: ' . $this->fileSize
84
+            'x-ton-expires: '.gmdate('D, d M Y H:i:s T', strtotime("+10 day")),
85
+            'content-type: '.$this->getContentType(),
86
+            'Content-Length: '.$this->fileSize
87 87
         ];
88 88
 
89
-        $response = $this->getTwitterAds()->post(self::DEFAULT_DOMAIN . self::DEFAULT_RESOURCE . self::DEFAULT_BUCKET, ['raw' => file_get_contents($this->filePath)], $headers);
89
+        $response = $this->getTwitterAds()->post(self::DEFAULT_DOMAIN.self::DEFAULT_RESOURCE.self::DEFAULT_BUCKET, ['raw' => file_get_contents($this->filePath)], $headers);
90 90
         return $response;
91 91
     }
92 92
 
93 93
     public function uploadChunk($resource, $chunkSize, $bytes, $bytesStart, $bytesRead)
94 94
     {
95 95
         $headers = [
96
-            'Content-Type: ' . $this->getContentType(),
97
-            'Content-Range: bytes ' . $bytesStart . '-' . ($bytesRead - 1) . '/' . $this->fileSize
96
+            'Content-Type: '.$this->getContentType(),
97
+            'Content-Range: bytes '.$bytesStart.'-'.($bytesRead - 1).'/'.$this->fileSize
98 98
         ];
99
-        $response = $this->getTwitterAds()->put(self::DEFAULT_DOMAIN . $resource, ['raw' => $bytes], $headers);
99
+        $response = $this->getTwitterAds()->put(self::DEFAULT_DOMAIN.$resource, ['raw' => $bytes], $headers);
100 100
 
101 101
         return $response;
102 102
     }
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
     public function initChunkedUpload()
105 105
     {
106 106
         $headers = [
107
-            'X-Ton-Content-Type: ' . $this->getContentType(),
108
-            'X-Ton-Content-Length: ' . $this->fileSize,
109
-            'X-Ton-Expires: ' . gmdate('D, d M Y H:i:s T', strtotime("+6 day")),
110
-            'Content-Type: ' . $this->getContentType(),
111
-            'Content-Length: ' . strval(0)
107
+            'X-Ton-Content-Type: '.$this->getContentType(),
108
+            'X-Ton-Content-Length: '.$this->fileSize,
109
+            'X-Ton-Expires: '.gmdate('D, d M Y H:i:s T', strtotime("+6 day")),
110
+            'Content-Type: '.$this->getContentType(),
111
+            'Content-Length: '.strval(0)
112 112
         ];
113 113
 
114
-        $resource = self::DEFAULT_DOMAIN . self::DEFAULT_RESOURCE . self::DEFAULT_BUCKET . '?resumable=true';
114
+        $resource = self::DEFAULT_DOMAIN.self::DEFAULT_RESOURCE.self::DEFAULT_BUCKET.'?resumable=true';
115 115
         $response = $this->getTwitterAds()->post($resource, [], $headers);
116 116
         return $response;
117 117
     }
Please login to merge, or discard this patch.
src/TwitterAds.php 2 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @param string $path
251 251
      * @param array $parameters
252 252
      *
253
-     * @param array $headers
253
+     * @param string[] $headers
254 254
      * @return Response
255 255
      */
256 256
     public function post($path, array $parameters = [], array $headers = [])
@@ -648,6 +648,10 @@  discard block
 block discarded – undo
648 648
     // This function takes a input like a=b&a=c&d=e and returns the parsed
649 649
     // parameters like this
650 650
     // array('a' => array('b','c'), 'd' => 'e')
651
+
652
+    /**
653
+     * @param string $input
654
+     */
651 655
     public static function parse_parameters($input)
652 656
     {
653 657
         if (!isset($input) || !$input) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         $this->response->setApiPath($path);
226 226
         $url = sprintf('%s/%s', self::API_HOST_OAUTH, $path);
227 227
         $request = Request::fromConsumerAndToken($this->consumer, $this->token, $method, $url, $parameters);
228
-        $authorization = 'Authorization: Basic ' . $this->encodeAppAuthorization($this->consumer);
228
+        $authorization = 'Authorization: Basic '.$this->encodeAppAuthorization($this->consumer);
229 229
         $result = $this->request($request->getNormalizedHttpUrl(), $method, $authorization, $parameters);
230 230
         $response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
231 231
         $this->response->setBody($response);
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
     public function manageErrors($response)
462 462
     {
463 463
         $errors = [];
464
-        if(isset($response->errors)){
464
+        if (isset($response->errors)) {
465 465
             $errors = $response->errors;
466
-        } else if(isset($response->operation_errors)){
466
+        } else if (isset($response->operation_errors)) {
467 467
             $errors = $response->operation_errors;
468 468
         }
469 469
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
             $request->signRequest($this->signatureMethod, $this->consumer, $this->token);
510 510
             $authorization = $request->toHeader();
511 511
         } else {
512
-            $authorization = 'Authorization: Bearer ' . $this->bearer;
512
+            $authorization = 'Authorization: Bearer '.$this->bearer;
513 513
         }
514 514
         if (strpos($url, TONUpload::DEFAULT_DOMAIN) === 0) {
515 515
             return $this->request($url, $method, $authorization, $parameters, $headers);
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         /* Curl settings */
536 536
         $options = [
537 537
             CURLOPT_VERBOSE => false,
538
-            CURLOPT_CAINFO => __DIR__ . DIRECTORY_SEPARATOR . 'cacert.pem',
538
+            CURLOPT_CAINFO => __DIR__.DIRECTORY_SEPARATOR.'cacert.pem',
539 539
             CURLOPT_CONNECTTIMEOUT => $this->connectionTimeout,
540 540
             CURLOPT_HEADER => true,
541 541
             CURLOPT_HTTPHEADER => array_merge(['Accept: */*', $authorization, 'Expect:'], $headers, ['Connection: close']),
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
         }
583 583
 
584 584
         if (in_array($method, ['GET', 'PUT', 'DELETE']) && !empty($postfields) && !isset($postfields['raw'])) {
585
-            $options[CURLOPT_URL] .= '?' . Util::buildHttpQuery($postfields);
585
+            $options[CURLOPT_URL] .= '?'.Util::buildHttpQuery($postfields);
586 586
         }
587 587
 
588 588
         $curlHandle = curl_init();
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         $key = $consumer->key;
659 659
         $secret = $consumer->secret;
660 660
 
661
-        return base64_encode($key . ':' . $secret);
661
+        return base64_encode($key.':'.$secret);
662 662
     }
663 663
 
664 664
     /**
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
      */
693 693
     public function getAccountId()
694 694
     {
695
-        if(!$this->account instanceof Account){
695
+        if (!$this->account instanceof Account) {
696 696
             return '';
697 697
         }
698 698
         return $this->account->getId();
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      */
704 704
     public function getAccountTimezone()
705 705
     {
706
-        if(!$this->account instanceof Account){
706
+        if (!$this->account instanceof Account) {
707 707
             return 'UTC';
708 708
         }
709 709
         return $this->account->getTimezone();
@@ -819,9 +819,9 @@  discard block
 block discarded – undo
819 819
             $token = $token['oauth_token'];
820 820
         }
821 821
         if (empty($sign_in_with_twitter)) {
822
-            return $this->authorizeURL() . "?oauth_token={$token}";
822
+            return $this->authorizeURL()."?oauth_token={$token}";
823 823
         } else {
824
-            return $this->authenticateURL() . "?oauth_token={$token}";
824
+            return $this->authenticateURL()."?oauth_token={$token}";
825 825
         }
826 826
     }
827 827
 }
Please login to merge, or discard this patch.
src/TwitterAds/Batch.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Hborras\TwitterAdsSDK\TwitterAds;
6 6
 use Hborras\TwitterAdsSDK\TwitterAds\Resource;
7
-use Hborras\TwitterAdsSDK\TwitterAds\Account;
8 7
 use Hborras\TwitterAdsSDK\Arrayable;
9 8
 use Hborras\TwitterAdsSDK\TwitterAds\Errors\BatchLimitExceeded;
10 9
 
Please login to merge, or discard this patch.
src/TwitterAds/Cursor.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@
 block discarded – undo
217 217
     /**
218 218
      * Return the key of the current element
219 219
      * @link http://php.net/manual/en/iterator.key.php
220
-     * @return mixed scalar on success, or null on failure.
220
+     * @return integer scalar on success, or null on failure.
221 221
      * @since 5.0.0
222 222
      */
223 223
     public function key()
Please login to merge, or discard this patch.
src/Util.php 1 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
         $output = '';
18 18
         if (is_array($input)) {
19
-            $output = array_map([__NAMESPACE__ . '\Util', 'urlencodeRfc3986'], $input);
19
+            $output = array_map([__NAMESPACE__.'\Util', 'urlencodeRfc3986'], $input);
20 20
         } elseif (is_scalar($input)) {
21 21
             $output = rawurlencode($input);
22 22
         }
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
                 // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
105 105
                 sort($value, SORT_STRING);
106 106
                 foreach ($value as $duplicateValue) {
107
-                    $pairs[] = $parameter . '=' . $duplicateValue;
107
+                    $pairs[] = $parameter.'='.$duplicateValue;
108 108
                 }
109 109
             } else {
110
-                $pairs[] = $parameter . '=' . $value;
110
+                $pairs[] = $parameter.'='.$value;
111 111
             }
112 112
         }
113 113
         // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
Please login to merge, or discard this patch.
src/Config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function setTimeouts($connectionTimeout, $timeout)
36 36
     {
37
-        $this->connectionTimeout = (int)$connectionTimeout;
38
-        $this->timeout = (int)$timeout;
37
+        $this->connectionTimeout = (int) $connectionTimeout;
38
+        $this->timeout = (int) $timeout;
39 39
     }
40 40
 
41 41
     /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function setDecodeJsonAsArray($value)
45 45
     {
46
-        $this->decodeJsonAsArray = (bool)$value;
46
+        $this->decodeJsonAsArray = (bool) $value;
47 47
     }
48 48
 
49 49
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function setUserAgent($userAgent)
53 53
     {
54
-        $this->userAgent = (string)$userAgent;
54
+        $this->userAgent = (string) $userAgent;
55 55
     }
56 56
 
57 57
     /**
Please login to merge, or discard this patch.
src/TwitterAds/Analytics.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
     {
38 38
         $endTime = isset($params[AnalyticsFields::END_TIME]) ? $params[AnalyticsFields::END_TIME] : new \DateTime('now');
39 39
         $endTime->setTime($endTime->format('H'), 0, 0);
40
-        $startTime = isset($params[AnalyticsFields::START_TIME]) ? $params[AnalyticsFields::START_TIME] : new \DateTime($endTime->format('c') . " - 7 days");
40
+        $startTime = isset($params[AnalyticsFields::START_TIME]) ? $params[AnalyticsFields::START_TIME] : new \DateTime($endTime->format('c')." - 7 days");
41 41
         $startTime->setTime($startTime->format('H'), 0, 0);
42 42
         $granularity = isset($params[AnalyticsFields::GRANULARITY]) ? $params[AnalyticsFields::GRANULARITY] : Enumerations::GRANULARITY_TOTAL;
43 43
         $placement = isset($params[AnalyticsFields::PLACEMENT]) ? $params[AnalyticsFields::PLACEMENT] : Enumerations::PLACEMENT_ALL_ON_TWITTER;
Please login to merge, or discard this patch.
src/Request.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $postData = $this->toPostdata();
179 179
         $out = $this->getNormalizedHttpUrl();
180 180
         if ($postData) {
181
-            $out .= '?' . $postData;
181
+            $out .= '?'.$postData;
182 182
         }
183 183
 
184 184
         return $out;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 throw new TwitterOAuthException('Arrays not supported in headers');
214 214
             }
215 215
             $out .= ($first) ? ' ' : ', ';
216
-            $out .= Util::urlencodeRfc3986($k) . '="' . Util::urlencodeRfc3986($v) . '"';
216
+            $out .= Util::urlencodeRfc3986($k).'="'.Util::urlencodeRfc3986($v).'"';
217 217
             $first = false;
218 218
         }
219 219
 
@@ -257,6 +257,6 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public static function generateNonce()
259 259
     {
260
-        return md5(microtime() . mt_rand());
260
+        return md5(microtime().mt_rand());
261 261
     }
262 262
 }
Please login to merge, or discard this patch.