Passed
Pull Request — develop (#68)
by
unknown
05:59
created
src/helpers/VideosHelper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public static function getDuration($seconds): string
32 32
     {
33
-        $hours = (int)((int)$seconds / 3600);
33
+        $hours = (int) ((int) $seconds / 3600);
34 34
         $minutes = (($seconds / 60) % 60);
35 35
         $seconds %= 60;
36 36
 
37 37
         $hms = '';
38 38
 
39 39
         if ($hours > 0) {
40
-            $hms .= str_pad($hours, 2, '0', STR_PAD_LEFT) . ':';
40
+            $hms .= str_pad($hours, 2, '0', STR_PAD_LEFT).':';
41 41
         }
42 42
 
43
-        $hms .= str_pad($minutes, 2, '0', STR_PAD_LEFT) . ':';
43
+        $hms .= str_pad($minutes, 2, '0', STR_PAD_LEFT).':';
44 44
 
45 45
         $hms .= str_pad($seconds, 2, '0', STR_PAD_LEFT);
46 46
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public static function getDuration8601($seconds): string
58 58
     {
59
-        $hours = (int)((int)$seconds / 3600);
59
+        $hours = (int) ((int) $seconds / 3600);
60 60
         $minutes = (($seconds / 60) % 60);
61 61
         $seconds %= 60;
62 62
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $iso8601 .= sprintf('%dM', $minutes);
71 71
         }
72 72
 
73
-        return $iso8601 . sprintf('%dS', $seconds);
73
+        return $iso8601.sprintf('%dS', $seconds);
74 74
     }
75 75
 
76 76
     /**
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public static function getVideoThumbnail($gatewayHandle, $videoId, $size): ?string
90 90
     {
91
-        $baseDir = Craft::$app->getPath()->getRuntimePath() . DIRECTORY_SEPARATOR . 'videos' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $gatewayHandle . DIRECTORY_SEPARATOR . $videoId;
92
-        $originalDir = $baseDir . DIRECTORY_SEPARATOR . 'original';
93
-        $dir = $baseDir . DIRECTORY_SEPARATOR . $size;
91
+        $baseDir = Craft::$app->getPath()->getRuntimePath().DIRECTORY_SEPARATOR.'videos'.DIRECTORY_SEPARATOR.'thumbnails'.DIRECTORY_SEPARATOR.$gatewayHandle.DIRECTORY_SEPARATOR.$videoId;
92
+        $originalDir = $baseDir.DIRECTORY_SEPARATOR.'original';
93
+        $dir = $baseDir.DIRECTORY_SEPARATOR.$size;
94 94
 
95 95
         $file = self::getThumbnailFile($dir);
96 96
 
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
                 try {
111 111
                     $video = Plugin::$plugin->getVideos()->getVideoById($gatewayHandle, $videoId);
112 112
                 } catch (ApiResponseException $apiResponseException) {
113
-                    Craft::info('Couldn’t get video thumbnail:' . "\r\n"
114
-                        . 'Message: ' . "\r\n" . $apiResponseException->getMessage() . "\r\n"
115
-                        . 'Trace: ' . "\r\n" . $apiResponseException->getTraceAsString(), __METHOD__);
113
+                    Craft::info('Couldn’t get video thumbnail:'."\r\n"
114
+                        . 'Message: '."\r\n".$apiResponseException->getMessage()."\r\n"
115
+                        . 'Trace: '."\r\n".$apiResponseException->getTraceAsString(), __METHOD__);
116 116
                     return null;
117 117
                 }
118 118
 
119 119
                 $url = $video->thumbnailSource;
120 120
 
121 121
                 $name = pathinfo($url, PATHINFO_BASENAME);
122
-                $originalPath = $originalDir . DIRECTORY_SEPARATOR . $name;
122
+                $originalPath = $originalDir.DIRECTORY_SEPARATOR.$name;
123 123
 
124 124
                 FileHelper::createDirectory($originalDir);
125 125
                 $client = new \GuzzleHttp\Client();
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
                     $ext = FileHelper::getExtensionByMimeType($mime);
137 137
 
138 138
                     if ($ext !== '' && $ext !== '0') {
139
-                        $name .= '.' . $ext;
140
-                        $targetPath = $originalDir . DIRECTORY_SEPARATOR . $name;
139
+                        $name .= '.'.$ext;
140
+                        $targetPath = $originalDir.DIRECTORY_SEPARATOR.$name;
141 141
 
142 142
                         rename($originalPath, $targetPath);
143 143
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             }
154 154
 
155 155
             // Generate the thumb
156
-            $path = $dir . DIRECTORY_SEPARATOR . $name;
156
+            $path = $dir.DIRECTORY_SEPARATOR.$name;
157 157
             FileHelper::createDirectory($dir);
158 158
             Craft::$app->getImages()->loadImage($originalPath, false, $size)
159 159
                 ->scaleToFit($size, $size)
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             $name = pathinfo($file, PATHINFO_BASENAME);
163 163
         }
164 164
 
165
-        return Craft::$app->getAssetManager()->getPublishedUrl($dir, true) . sprintf('/%s', $name);
165
+        return Craft::$app->getAssetManager()->getPublishedUrl($dir, true).sprintf('/%s', $name);
166 166
     }
167 167
 
168 168
     /**
Please login to merge, or discard this patch.
src/base/Gateway.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
             // Redirect
170 170
             Craft::$app->getSession()->setNotice(Craft::t('videos', 'Connected to {gateway}.', ['gateway' => $this->getName()]));
171 171
         } catch (Exception $exception) {
172
-            Craft::error('Couldn’t connect to video gateway:' . "\r\n"
173
-                . 'Message: ' . "\r\n" . $exception->getMessage() . "\r\n"
174
-                . 'Trace: ' . "\r\n" . $exception->getTraceAsString(), __METHOD__);
172
+            Craft::error('Couldn’t connect to video gateway:'."\r\n"
173
+                . 'Message: '."\r\n".$exception->getMessage()."\r\n"
174
+                . 'Trace: '."\r\n".$exception->getTraceAsString(), __METHOD__);
175 175
 
176 176
             // Failed to get the token credentials or user details.
177 177
             Craft::$app->getSession()->setError($exception->getMessage());
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     public function getEmbedHtml($videoId, array $options = []): string
227 227
     {
228 228
         $embedAttributes = [
229
-            'title' => 'External video from ' . $this->getHandle(),
229
+            'title' => 'External video from '.$this->getHandle(),
230 230
             'frameborder' => '0',
231 231
             'allowfullscreen' => 'true',
232 232
             'allowscriptaccess' => 'true',
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
         $embedAttributesString = '';
254 254
 
255 255
         foreach ($embedAttributes as $key => $value) {
256
-            $embedAttributesString .= ' ' . $key . '="' . $value . '"';
256
+            $embedAttributesString .= ' '.$key.'="'.$value.'"';
257 257
         }
258 258
 
259
-        return '<iframe src="' . $embedUrl . '"' . $embedAttributesString . '></iframe>';
259
+        return '<iframe src="'.$embedUrl.'"'.$embedAttributesString.'></iframe>';
260 260
     }
261 261
 
262 262
     /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
             $options = http_build_query($options);
282 282
 
283
-            $format .= $queryMark . $options;
283
+            $format .= $queryMark.$options;
284 284
         }
285 285
 
286 286
         return sprintf($format, $videoId);
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
      */
358 358
     public function getVideos($method, $options)
359 359
     {
360
-        $realMethod = 'getVideos' . ucwords($method);
360
+        $realMethod = 'getVideos'.ucwords($method);
361 361
 
362 362
         if (method_exists($this, $realMethod)) {
363 363
             return $this->{$realMethod}($options);
364 364
         }
365 365
 
366
-        throw new GatewayMethodNotFoundException('Gateway method “' . $realMethod . '” not found.');
366
+        throw new GatewayMethodNotFoundException('Gateway method “'.$realMethod.'” not found.');
367 367
     }
368 368
 
369 369
     /**
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
                 Craft::info('Vimeo X-RateLimit-Remaining: '.Json::encode($response->getHeader('X-RateLimit-Remaining')), __METHOD__);
425 425
             }
426 426
 
427
-            $body = (string)$response->getBody();
427
+            $body = (string) $response->getBody();
428 428
             $data = Json::decode($body);
429 429
         } catch (BadResponseException $badResponseException) {
430 430
             $response = $badResponseException->getResponse();
431
-            $body = (string)$response->getBody();
431
+            $body = (string) $response->getBody();
432 432
 
433 433
             try {
434 434
                 $data = Json::decode($body);
Please login to merge, or discard this patch.