Completed
Push — master ( d0121a...036b67 )
by Nicolas
02:10
created
src/activities/transcoders/AudioTranscoder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/BasicTranscoder.php';
3
+require_once __DIR__.'/BasicTranscoder.php';
4 4
 
5 5
 class AudioTranscoder extends BasicTranscoder
6 6
 {
Please login to merge, or discard this patch.
src/activities/transcoders/ImageTranscoder.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -21,6 +21,12 @@
 block discarded – undo
21 21
     // $metadata should contain the ffprobe video stream array.
22 22
 
23 23
     // Start Convert for output transcoding
24
+
25
+    /**
26
+     * @param string $tmpPathInput
27
+     * @param null|string $pathToInputFile
28
+     * @param string $pathToOutputFiles
29
+     */
24 30
     public function transcode_asset(
25 31
         $tmpPathInput,
26 32
         $pathToInputFile, 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $this->cpeLogger->logOut(
59 59
                 "INFO", 
60 60
                 basename(__FILE__), 
61
-                "Input Video metadata: " . print_r($metadata, true),
61
+                "Input Video metadata: ".print_r($metadata, true),
62 62
                 $this->activityLogKey
63 63
             );
64 64
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             $this->cpeLogger->logOut(
133 133
                 "ERROR", 
134 134
                 basename(__FILE__), 
135
-                "Execution of command '".$convertCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
135
+                "Execution of command '".$convertCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
136 136
                 $this->activityLogKey
137 137
             );
138 138
             return false;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         
185 185
         // Append output filename to path
186 186
         $pathToOutputFiles .=
187
-            "/" . $outputWanted->{'output_file_info'}['basename'];
187
+            "/".$outputWanted->{'output_file_info'}['basename'];
188 188
         
189 189
         $convertCmd = "convert $convertArgs $pathToOutputFiles";
190 190
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             $pathToInputFile, $convertCmd);
208 208
 
209 209
         // Append output filename to path
210
-        $pathToOutputFiles .= "/" . $outputWanted->{'output_file_info'}['basename'];
210
+        $pathToOutputFiles .= "/".$outputWanted->{'output_file_info'}['basename'];
211 211
         // Replace ${output_file} by output filename and path to local disk
212 212
         $convertCmd = preg_replace('/\$\{output_file\}/',
213 213
             $pathToOutputFiles, $convertCmd);
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,13 +54,14 @@  discard block
 block discarded – undo
54 54
             $this->activityLogKey
55 55
         );
56 56
 
57
-        if ($metadata)
58
-            $this->cpeLogger->logOut(
57
+        if ($metadata) {
58
+                    $this->cpeLogger->logOut(
59 59
                 "INFO", 
60 60
                 basename(__FILE__), 
61 61
                 "Input Video metadata: " . print_r($metadata, true),
62 62
                 $this->activityLogKey
63 63
             );
64
+        }
64 65
 
65 66
         try {
66 67
             $convertCmd = "";
@@ -81,8 +82,7 @@  discard block
 block discarded – undo
81 82
                     $metadata, 
82 83
                     $outputWanted
83 84
                 );
84
-            }
85
-            else {
85
+            } else {
86 86
                 $convertCmd = $this->craft_convert_cmd(
87 87
                     $tmpPathInput,
88 88
                     $pathToInputFile,
@@ -127,8 +127,7 @@  discard block
 block discarded – undo
127 127
             // XXX: Remove FFprobe for image convertion. Save time
128 128
             $outputInfo =
129 129
                 $this->getAssetInfo($pathToOutputFiles."/".$outputWanted->{'output_file_info'}['basename']);
130
-        }
131
-        catch (\Exception $e) {
130
+        } catch (\Exception $e) {
132 131
             $this->cpeLogger->logOut(
133 132
                 "ERROR", 
134 133
                 basename(__FILE__), 
Please login to merge, or discard this patch.
src/activities/BasicActivity.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -113,6 +113,10 @@
 block discarded – undo
113 113
      */
114 114
     
115 115
     // Create TMP folder and download file to process
116
+
117
+    /**
118
+     * @param string $saveFileTo
119
+     */
116 120
     public function getFileToProcess($task, $inputBuket, $inputFile, $saveFileTo)
117 121
     {        
118 122
         // Get file from S3 or local copy if any
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
         {
79 79
             if ($this->debug)
80 80
                 $this->cpeLogger->logOut("DEBUG", basename(__FILE__), 
81
-                                         "Creating TMP input folder '".$this->tmpInputPath."'",
82
-                                         $this->logKey);
81
+                                            "Creating TMP input folder '".$this->tmpInputPath."'",
82
+                                            $this->logKey);
83 83
             
84 84
             if (!mkdir($this->tmpInputPath, 0750, true))
85 85
                 throw new CpeSdk\CpeException(
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     {        
118 118
         // Get file from S3 or local copy if any
119 119
         $this->cpeLogger->logOut("INFO", 
120
-                                 basename(__FILE__), 
121
-                                 "Downloading '$inputBuket/$inputFile' to '$saveFileTo' ...",
122
-                                 $this->logKey);
120
+                                    basename(__FILE__), 
121
+                                    "Downloading '$inputBuket/$inputFile' to '$saveFileTo' ...",
122
+                                    $this->logKey);
123 123
         
124 124
         // Use the S3 utils to initiate the download
125 125
         $s3Output = $this->s3Utils->get_file_from_s3(
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
         );
133 133
         
134 134
         $this->cpeLogger->logOut("INFO", basename(__FILE__), 
135
-                                 $s3Output['msg'],
136
-                                 $this->logKey);
135
+                                    $s3Output['msg'],
136
+                                    $this->logKey);
137 137
         
138 138
         $this->cpeLogger->logOut("INFO", basename(__FILE__), 
139
-                                 "Input file successfully downloaded into local TMP folder '$saveFileTo' !",
140
-                                 $this->logKey);
139
+                                    "Input file successfully downloaded into local TMP folder '$saveFileTo' !",
140
+                                    $this->logKey);
141 141
         
142 142
         return $saveFileTo;
143 143
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 
28 28
 class BasicActivity extends CpeSdk\CpeActivity
29 29
 {
30
-    public $tmpInputPath;    // Path to directory containing TMP file
31
-    public $inputFilePath;   // Path to input file locally
32
-    public $s3Utils;         // Used to manipulate S3. Download/Upload
30
+    public $tmpInputPath; // Path to directory containing TMP file
31
+    public $inputFilePath; // Path to input file locally
32
+    public $s3Utils; // Used to manipulate S3. Download/Upload
33 33
   
34 34
     // Constants
35 35
     const TMP_FOLDER_FAIL      = "TMP_FOLDER_FAIL";
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         if (isset($this->input->{'input_asset'}->{'http'}))
93 93
         {
94 94
             // Pad HTTP input so it is cached in case of full encodes
95
-            $this->inputFilePath = 'cache:' . $this->input->{'input_asset'}->{'http'};
95
+            $this->inputFilePath = 'cache:'.$this->input->{'input_asset'}->{'http'};
96 96
         }
97 97
         else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
98 98
                  isset($this->input->{'input_asset'}->{'file'}))
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,16 +76,18 @@  discard block
 block discarded – undo
76 76
         // Create the tmp folder if doesn't exist
77 77
         if (!file_exists($this->tmpInputPath)) 
78 78
         {
79
-            if ($this->debug)
80
-                $this->cpeLogger->logOut("DEBUG", basename(__FILE__), 
79
+            if ($this->debug) {
80
+                            $this->cpeLogger->logOut("DEBUG", basename(__FILE__), 
81 81
                                          "Creating TMP input folder '".$this->tmpInputPath."'",
82 82
                                          $this->logKey);
83
+            }
83 84
             
84
-            if (!mkdir($this->tmpInputPath, 0750, true))
85
-                throw new CpeSdk\CpeException(
85
+            if (!mkdir($this->tmpInputPath, 0750, true)) {
86
+                            throw new CpeSdk\CpeException(
86 87
                     "Unable to create temporary folder '$this->tmpInputPath' !",
87 88
                     self::TMP_FOLDER_FAIL
88 89
                 );
90
+            }
89 91
         }
90 92
         
91 93
         $this->inputFilePath = null;
@@ -93,8 +95,7 @@  discard block
 block discarded – undo
93 95
         {
94 96
             // Pad HTTP input so it is cached in case of full encodes
95 97
             $this->inputFilePath = 'cache:' . $this->input->{'input_asset'}->{'http'};
96
-        }
97
-        else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
98
+        } else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
98 99
                  isset($this->input->{'input_asset'}->{'file'}))
99 100
         {
100 101
             // Download input file and store it in TMP folder
Please login to merge, or discard this patch.
src/activities/transcoders/BasicTranscoder.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -78,6 +78,10 @@
 block discarded – undo
78 78
      */
79 79
 
80 80
     // Execute FFPROBE to get asset information
81
+
82
+    /**
83
+     * @param string|null $inputFilePath
84
+     */
81 85
     public function getAssetInfo($inputFilePath)
82 86
     {
83 87
         $inputFilePath = escapeshellarg($inputFilePath);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
 class BasicTranscoder 
30 30
 {
31 31
     public $activityObj; // Calling activity object
32
-    public $task;        // Activity TASK
33
-    public $logKey;      // Valling activity loggin key
32
+    public $task; // Activity TASK
33
+    public $logKey; // Valling activity loggin key
34 34
 
35
-    public $cpeLogger;   // Logger
36
-    public $s3Utils;     // Used to manipulate S3
37
-    public $executer;    // Executer obj
35
+    public $cpeLogger; // Logger
36
+    public $s3Utils; // Used to manipulate S3
37
+    public $executer; // Executer obj
38 38
 
39 39
     const EXEC_VALIDATE_FAILED  = "EXEC_VALIDATE_FAILED";
40 40
     const TRANSCODE_FAIL        = "TRANSCODE_FAIL";
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function isDirEmpty($dir)
61 61
     {
62
-        if (!is_readable($dir)) return null; 
62
+        if (!is_readable($dir)) {
63
+            return null;
64
+        }
63 65
         $handle = opendir($dir);
64 66
         while (false !== ($entry = readdir($handle))) {
65 67
             if ($entry !== '.' && $entry !== '..') { 
@@ -94,8 +96,7 @@  discard block
 block discarded – undo
94 96
                 false, false, 
95 97
                 false, 1
96 98
             );
97
-        }
98
-        catch (\Exception $e) {
99
+        } catch (\Exception $e) {
99 100
             $this->cpeLogger->logOut(
100 101
                 "ERROR", 
101 102
                 basename(__FILE__), 
Please login to merge, or discard this patch.
src/activities/transcoders/VideoTranscoder.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -55,6 +55,12 @@
 block discarded – undo
55 55
     // $metadata should contain the ffprobe video stream array.
56 56
 
57 57
     // Start FFmpeg for output transcoding
58
+
59
+    /**
60
+     * @param string $tmpInputPath
61
+     * @param null|string $inputFilePath
62
+     * @param string $outputFilesPath
63
+     */
58 64
     public function transcode_asset(
59 65
         $tmpInputPath,
60 66
         $inputFilePath,
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
         // Process options for watermark
209 209
         if (isset($outputWanted->{'watermark'}) && $outputWanted->{'watermark'}) {
210 210
             $watermarkOptions =
211
-                              $this->get_watermark_options(
212
-                                  $tmpInputPath,
213
-                                  $outputWanted->{'watermark'});
211
+                                $this->get_watermark_options(
212
+                                    $tmpInputPath,
213
+                                    $outputWanted->{'watermark'});
214 214
             // Replace ${watermark_options} by watermark options
215 215
             $ffmpegCmd = preg_replace('/\$\{watermark_options\}/', $watermarkOptions, $ffmpegCmd);
216 216
         }
@@ -263,16 +263,16 @@  discard block
 block discarded – undo
263 263
         $formattedOptions = "";
264 264
         if (isset($outputWanted->{'preset_values'}->{'video_codec_options'})) {
265 265
             $formattedOptions =
266
-                              $this->set_output_video_codec_options($outputWanted->{'preset_values'}->{'video_codec_options'});
266
+                                $this->set_output_video_codec_options($outputWanted->{'preset_values'}->{'video_codec_options'});
267 267
         }
268 268
 
269 269
         $watermarkOptions = "";
270 270
         // Process options for watermark
271 271
         if (isset($outputWanted->{'watermark'}) && $outputWanted->{'watermark'}) {
272 272
             $watermarkOptions =
273
-                              $this->get_watermark_options(
274
-                                  $tmpInputPath,
275
-                                  $outputWanted->{'watermark'});
273
+                                $this->get_watermark_options(
274
+                                    $tmpInputPath,
275
+                                    $outputWanted->{'watermark'});
276 276
         }
277 277
 
278 278
         // Create FFMpeg arguments
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             }
330 330
 
331 331
             $outputFilesPath .= "/" . $outputFileInfo['filename'] . "%06d."
332
-                             . $outputFileInfo['extension'];
332
+                                . $outputFileInfo['extension'];
333 333
             $frameOptions = " -vf fps=fps=1/$intervals";
334 334
         }
335 335
 
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
             $watermarkPath);
362 362
 
363 363
         $this->cpeLogger->logOut("INFO",
364
-                                 basename(__FILE__),
365
-                                 $s3Output['msg'],
366
-                                 $this->logKey);
364
+                                    basename(__FILE__),
365
+                                    $s3Output['msg'],
366
+                                    $this->logKey);
367 367
 
368 368
         // Transform watermark for opacity
369 369
         $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath";
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
     {
551 551
         if (!$output_wanted) {
552 552
             throw new CpeSdk\CpeException("No output data provided to transcoder !",
553
-                                          self::NO_OUTPUT);
553
+                                            self::NO_OUTPUT);
554 554
         }
555 555
 
556 556
         if (!isset($output_wanted->{"preset"})) {
557 557
             throw new CpeSdk\CpeException("No preset selected for output !",
558
-                                          self::BAD_PRESETS_DIR);
558
+                                            self::BAD_PRESETS_DIR);
559 559
         }
560 560
 
561 561
         $preset     = $output_wanted->{"preset"};
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
 
564 564
         if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) {
565 565
             throw new CpeSdk\CpeException("Can't open preset file !",
566
-                                          self::OPEN_PRESET_FAILED);
566
+                                            self::OPEN_PRESET_FAILED);
567 567
         }
568 568
 
569 569
         if (!($decodedPreset = json_decode($presetContent))) {
570 570
             throw new CpeSdk\CpeException("Bad preset JSON format !",
571
-                                          self::BAD_PRESET_FORMAT);
571
+                                            self::BAD_PRESET_FORMAT);
572 572
         }
573 573
 
574 574
         return ($decodedPreset);
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
     {
580 580
         if (!isset($output->{"preset"})) {
581 581
             throw new CpeSdk\CpeException("No preset selected for output !",
582
-                                          self::BAD_PRESETS_DIR);
582
+                                            self::BAD_PRESETS_DIR);
583 583
         }
584 584
 
585 585
         $preset     = $output->{"preset"};
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 
588 588
         if (!($files = scandir($presetPath))) {
589 589
             throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !",
590
-                                          self::BAD_PRESETS_DIR);
590
+                                            self::BAD_PRESETS_DIR);
591 591
         }
592 592
 
593 593
         foreach ($files as $presetFile)
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
                 {
601 601
                     if (!($presetContent = file_get_contents("$presetPath/$presetFile"))) {
602 602
                         throw new CpeSdk\CpeException("Can't open preset file '$presetPath/$presetFile'!",
603
-                                                      self::OPEN_PRESET_FAILED);
603
+                                                        self::OPEN_PRESET_FAILED);
604 604
                     }
605 605
 
606 606
                     if (!($decodedPreset = json_decode($presetContent))) {
607 607
                         throw new CpeSdk\CpeException("Bad preset JSON format '$presetPath/$presetFile'!",
608
-                                                      self::BAD_PRESET_FORMAT);
608
+                                                        self::BAD_PRESET_FORMAT);
609 609
                     }
610 610
 
611 611
                     return true;
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
         }
615 615
 
616 616
         throw new CpeSdk\CpeException("Unkown preset file '$preset' !",
617
-                                      self::UNKNOWN_PRESET);
617
+                                        self::UNKNOWN_PRESET);
618 618
     }
619 619
 
620 620
     // Extract Metadata from ffprobe
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 23
  */
24 24
 
25
-require_once __DIR__ . '/BasicTranscoder.php';
25
+require_once __DIR__.'/BasicTranscoder.php';
26 26
 
27 27
 use SA\CpeSdk;
28 28
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $this->cpeLogger->logOut(
85 85
                 "INFO",
86 86
                 basename(__FILE__),
87
-                "Input Video metadata: " . print_r($metadata, true),
87
+                "Input Video metadata: ".print_r($metadata, true),
88 88
                 $this->logKey
89 89
             );
90 90
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $this->cpeLogger->logOut(
171 171
                 "ERROR",
172 172
                 basename(__FILE__),
173
-                "Execution of command '".$ffmpegCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(),
173
+                "Execution of command '".$ffmpegCmd."' failed: ".print_r($metadata, true).". ".$e->getMessage(),
174 174
                 $this->logKey
175 175
             );
176 176
             throw $e;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         }
217 217
 
218 218
         // Append output filename to path
219
-        $outputFilesPath .= "/" . $outputWanted->{'output_file_info'}['basename'];
219
+        $outputFilesPath .= "/".$outputWanted->{'output_file_info'}['basename'];
220 220
         // Replace ${output_file} by output filename and path to local disk
221 221
         $ffmpegCmd = preg_replace('/\$\{output_file\}/', $outputFilesPath, $ffmpegCmd);
222 222
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         // Create FFMpeg arguments
279
-        $ffmpegArgs =  " -i $inputFilePath -y -threads 0";
279
+        $ffmpegArgs = " -i $inputFilePath -y -threads 0";
280 280
         $ffmpegArgs .= " -vf scale=$size";
281 281
         $ffmpegArgs .= " -vcodec $videoCodec";
282 282
         $ffmpegArgs .= " -acodec $audioCodec";
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
         $ffmpegArgs .= " $watermarkOptions";
288 288
 
289 289
         // Append output filename to path
290
-        $outputFilesPath .= "/" . $outputWanted->{'output_file_info'}['basename'];
290
+        $outputFilesPath .= "/".$outputWanted->{'output_file_info'}['basename'];
291 291
         // Final command
292
-        $ffmpegCmd  = "ffmpeg $ffmpegArgs $outputFilesPath";
292
+        $ffmpegCmd = "ffmpeg $ffmpegArgs $outputFilesPath";
293 293
 
294 294
         return ($ffmpegCmd);
295 295
     }
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
                 $snapshot_sec = $outputWanted->{'snapshot_sec'};
317 317
             }
318 318
 
319
-            $time = gmdate("H:i:s", $snapshot_sec) . ".000";
320
-            $outputFilesPath .= "/" . $outputFileInfo['basename'];
319
+            $time = gmdate("H:i:s", $snapshot_sec).".000";
320
+            $outputFilesPath .= "/".$outputFileInfo['basename'];
321 321
             $frameOptions = " -ss $time -vframes 1";
322 322
         }
323 323
         else if ($outputWanted->{'mode'} == 'intervals')
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
                 $intervals = $outputWanted->{'intervals'};
329 329
             }
330 330
 
331
-            $outputFilesPath .= "/" . $outputFileInfo['filename'] . "%06d."
331
+            $outputFilesPath .= "/".$outputFileInfo['filename']."%06d."
332 332
                              . $outputFileInfo['extension'];
333 333
             $frameOptions = " -vf fps=fps=1/$intervals";
334 334
         }
335 335
 
336 336
         // Create FFMpeg arguments
337
-        $ffmpegArgs  =  " -i $inputFilePath -y -threads 0";
338
-        $ffmpegArgs .= " -vf scale=" . $outputWanted->{'size'};
337
+        $ffmpegArgs  = " -i $inputFilePath -y -threads 0";
338
+        $ffmpegArgs .= " -vf scale=".$outputWanted->{'size'};
339 339
         $ffmpegArgs .= " $frameOptions -f image2 -q:v 8";
340 340
 
341 341
         // Final command
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                                  $this->logKey);
367 367
 
368 368
         // Transform watermark for opacity
369
-        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply " . $watermarkOptions->{'opacity'} . " +channel $newWatermarkPath";
369
+        $convertCmd = "convert $watermarkPath -alpha on -channel A -evaluate Multiply ".$watermarkOptions->{'opacity'}." +channel $newWatermarkPath";
370 370
 
371 371
         try {
372 372
             $out = $this->executer->execute($convertCmd, 1,
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         // Format options for FFMpeg
396 396
         $size      = $watermarkOptions->{'size'};
397 397
         $positions = $this->get_watermark_position($watermarkOptions);
398
-        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=" . $positions['x'] . ':' . $positions['y'] . " [out]\"";
398
+        $formattedOptions = "-vf \"movie=$newWatermarkPath, scale=$size [wm]; [in][wm] overlay=".$positions['x'].':'.$positions['y']." [out]\"";
399 399
 
400 400
         return ($formattedOptions);
401 401
     }
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
             $positions['y'] = $watermarkOptions->{'y'};
413 413
         }
414 414
         if ($watermarkOptions->{'x'} < 0) {
415
-            $positions['x'] = 'main_w-overlay_w' . $watermarkOptions->{'x'};
415
+            $positions['x'] = 'main_w-overlay_w'.$watermarkOptions->{'x'};
416 416
         }
417 417
         if ($watermarkOptions->{'y'} < 0) {
418
-            $positions['y'] = 'main_h-overlay_h' . $watermarkOptions->{'y'};
418
+            $positions['y'] = 'main_h-overlay_h'.$watermarkOptions->{'y'};
419 419
         }
420 420
 
421 421
         return ($positions);
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
         }
492 492
 
493
-        return (str_replace("x",":", $size));
493
+        return (str_replace("x", ":", $size));
494 494
     }
495 495
 
496 496
     // REad ffmpeg output and calculate % progress
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
         // # finally, progress is easy
526 526
         if ($done && $duration) {
527
-            $progress = round(($done/$duration)*100);
527
+            $progress = round(($done / $duration) * 100);
528 528
         }
529 529
 
530 530
         $this->cpeLogger->logOut(
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         }
560 560
 
561 561
         $preset     = $output_wanted->{"preset"};
562
-        $presetPath = __DIR__ . '/../../../presets/';
562
+        $presetPath = __DIR__.'/../../../presets/';
563 563
 
564 564
         if (!($presetContent = file_get_contents($presetPath.$preset.".json"))) {
565 565
             throw new CpeSdk\CpeException("Can't open preset file !",
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
         }
584 584
 
585 585
         $preset     = $output->{"preset"};
586
-        $presetPath = __DIR__ . '/../../../presets/';
586
+        $presetPath = __DIR__.'/../../../presets/';
587 587
 
588 588
         if (!($files = scandir($presetPath))) {
589 589
             throw new CpeSdk\CpeException("Unable to open preset directory '$presetPath' !",
@@ -633,22 +633,22 @@  discard block
 block discarded – undo
633 633
         }
634 634
 
635 635
         $analyse = [
636
-            'duration' => isset($metadata->format->duration) ? (float)$metadata->format->duration : 0,
636
+            'duration' => isset($metadata->format->duration) ? (float) $metadata->format->duration : 0,
637 637
             'video' => empty($videoStreams) ? null : [
638 638
                 'codec' => $videoStreams->codec_name,
639 639
                 'color' => @$videoStreams->color_space,
640
-                'resolution' => $videoStreams->width . 'x' . $videoStreams->height,
640
+                'resolution' => $videoStreams->width.'x'.$videoStreams->height,
641 641
                 'sar' => $videoStreams->sample_aspect_ratio,
642 642
                 'dar' => $videoStreams->display_aspect_ratio,
643 643
                 'framerate' => $videoStreams->r_frame_rate,
644
-                'bitrate' => isset($videoStreams->bit_rate) ? (int)$videoStreams->bit_rate : null
644
+                'bitrate' => isset($videoStreams->bit_rate) ? (int) $videoStreams->bit_rate : null
645 645
             ],
646 646
             'audio' => empty($audioStreams) ? null : [
647 647
                 'codec' => $audioStreams->codec_name,
648 648
                 'frequency' => $audioStreams->sample_rate,
649
-                'channels' => (int)$audioStreams->channels,
649
+                'channels' => (int) $audioStreams->channels,
650 650
                 'depth' => $audioStreams->bits_per_sample,
651
-                'bitrate' => (int)$audioStreams->bit_rate
651
+                'bitrate' => (int) $audioStreams->bit_rate
652 652
             ]
653 653
         ];
654 654
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -10 removed lines patch added patch discarded remove patch
@@ -80,13 +80,14 @@  discard block
 block discarded – undo
80 80
             $this->logKey
81 81
         );
82 82
 
83
-        if ($metadata)
84
-            $this->cpeLogger->logOut(
83
+        if ($metadata) {
84
+                    $this->cpeLogger->logOut(
85 85
                 "INFO",
86 86
                 basename(__FILE__),
87 87
                 "Input Video metadata: " . print_r($metadata, true),
88 88
                 $this->logKey
89 89
             );
90
+        }
90 91
 
91 92
         try {
92 93
             $ffmpegCmd = "";
@@ -165,8 +166,7 @@  discard block
 block discarded – undo
165 166
 
166 167
             // FFProbe the output file and return its information
167 168
             $outputInfo = $this->getAssetInfo($outputFilesPath."/".$outputWanted->{'output_file_info'}['basename']);
168
-        }
169
-        catch (\Exception $e) {
169
+        } catch (\Exception $e) {
170 170
             $this->cpeLogger->logOut(
171 171
                 "ERROR",
172 172
                 basename(__FILE__),
@@ -319,8 +319,7 @@  discard block
 block discarded – undo
319 319
             $time = gmdate("H:i:s", $snapshot_sec) . ".000";
320 320
             $outputFilesPath .= "/" . $outputFileInfo['basename'];
321 321
             $frameOptions = " -ss $time -vframes 1";
322
-        }
323
-        else if ($outputWanted->{'mode'} == 'intervals')
322
+        } else if ($outputWanted->{'mode'} == 'intervals')
324 323
         {
325 324
             $intervals = self::INTERVALS_DEFAULT;
326 325
             if (isset($outputWanted->{'intervals'}) &&
@@ -373,8 +372,7 @@  discard block
 block discarded – undo
373 372
                                             array(1 => array("pipe", "w"), 2 => array("pipe", "w")),
374 373
                                             false, false,
375 374
                                             false, 1);
376
-        }
377
-        catch (\Exception $e) {
375
+        } catch (\Exception $e) {
378 376
             $this->cpeLogger->logOut(
379 377
                 "ERROR",
380 378
                 basename(__FILE__),
@@ -626,8 +624,7 @@  discard block
 block discarded – undo
626 624
         foreach ($metadata->streams as $key => $value) {
627 625
             if ($value->codec_type === 'video') {
628 626
                 $videoStreams = $value;
629
-            }
630
-            else if ($value->codec_type === 'audio') {
627
+            } else if ($value->codec_type === 'audio') {
631 628
                 $audioStreams = $value;
632 629
             }
633 630
         }
Please login to merge, or discard this patch.
src/activities/TranscodeAssetActivity.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 break;
80 80
             default:
81 81
                 throw new CpeSdk\CpeException("Unknown input asset 'type'! Abording ...",
82
-                                              self::UNKOWN_INPUT_TYPE);
82
+                                                self::UNKOWN_INPUT_TYPE);
83 83
             }
84 84
 
85 85
             // Upload resulting file
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         // Open '$outputFilesPath' to read it and send all files to S3 bucket
179 179
         if (!$handle = opendir($this->outputFilesPath)) {
180 180
             throw new CpeSdk\CpeException("Can't open tmp path '$this->outputFilesPath'!",
181
-                                          self::TMP_PATH_OPEN_FAIL);
181
+                                            self::TMP_PATH_OPEN_FAIL);
182 182
         }
183 183
 
184 184
         // Upload all resulting files sitting in $outputFilesPath to S3
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
             unlink("$this->outputFilesPath/$entry");
206 206
 
207 207
             $this->cpeLogger->logOut("INFO", basename(__FILE__),
208
-                                     $s3Output['msg'],
209
-                                     $this->logKey);
208
+                                        $s3Output['msg'],
209
+                                        $this->logKey);
210 210
         }
211 211
     }
212 212
 
213 213
     private function getOutputPath($output)
214 214
     {
215 215
         $outputFilesPath = self::TMP_FOLDER
216
-                         . $this->name."/".$this->logKey;
216
+                            . $this->name."/".$this->logKey;
217 217
 
218 218
         $output->{'key'} = $output->{'path'}."/".$output->{'file'};
219 219
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
         {
227 227
             if ($this->debug)
228 228
                 $this->cpeLogger->logOut("INFO", basename(__FILE__),
229
-                                         "Creating TMP output folder '".$outputFilesPath."'",
230
-                                         $this->logKey);
229
+                                            "Creating TMP output folder '".$outputFilesPath."'",
230
+                                            $this->logKey);
231 231
 
232 232
             if (!mkdir($outputFilesPath, 0750, true))
233 233
                 throw new CpeSdk\CpeException(
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             ))
267 267
         {
268 268
             throw new CpeSdk\CpeException("Can't convert that input asset 'type' (".$this->input->{'input_asset'}->{'type'}.") into this output asset 'type' (".$output->{'type'}.")! Abording.",
269
-                                          self::CONVERSION_TYPE_ERROR);
269
+                                            self::CONVERSION_TYPE_ERROR);
270 270
         }
271 271
     }
272 272
 }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 $cpeLogger = new SA\CpeSdk\CpeLogger($name, $logPath);
352 352
 $cpeLogger->logOut("INFO", basename(__FILE__),
353
-                   "\033[1mStarting activity\033[0m: $name");
353
+                    "\033[1mStarting activity\033[0m: $name");
354 354
 
355 355
 // We instanciate the Activity 'ValidateAsset' and give it a name for Snf
356 356
 $activityPoller = new TranscodeAssetActivity(
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -281,7 +281,7 @@
 block discarded – undo
281 281
 // Usage
282 282
 function usage()
283 283
 {
284
-    echo("Usage: php ". basename(__FILE__) . " -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
284
+    echo("Usage: php ".basename(__FILE__)." -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
285 285
     echo("-h: Print this help\n");
286 286
     echo("-d: Debug mode\n");
287 287
     echo("-l <log_path>: Location where logs will be dumped in (folder).\n");
Please login to merge, or discard this patch.
Braces   +28 added lines, -19 removed lines patch added patch discarded remove patch
@@ -85,8 +85,9 @@  discard block
 block discarded – undo
85 85
             // Upload resulting file
86 86
             $this->uploadResultFiles($task, $output);
87 87
 
88
-            if ($this->client)
89
-                $this->client->onTranscodeDone($this->token, $result);
88
+            if ($this->client) {
89
+                            $this->client->onTranscodeDone($this->token, $result);
90
+            }
90 91
         }
91 92
 
92 93
         return json_encode($result);
@@ -102,8 +103,9 @@  discard block
 block discarded – undo
102 103
         
103 104
         # If we have metadata, we expect the output of ffprobe
104 105
         $metadata = null;
105
-        if (isset($this->input->{'input_metadata'}))
106
-            $metadata = $this->input->{'input_metadata'};
106
+        if (isset($this->input->{'input_metadata'})) {
107
+                    $metadata = $this->input->{'input_metadata'};
108
+        }
107 109
         
108 110
         // Perform transcoding
109 111
         $result = $imageTranscoder->transcode_asset(
@@ -140,8 +142,9 @@  discard block
 block discarded – undo
140 142
 
141 143
         # If we have metadata, we expect the output of ffprobe
142 144
         $metadata = null;
143
-        if (isset($this->input->{'input_metadata'}))
144
-            $metadata = $this->input->{'input_metadata'};
145
+        if (isset($this->input->{'input_metadata'})) {
146
+                    $metadata = $this->input->{'input_metadata'};
147
+        }
145 148
 
146 149
         // Perform transcoding
147 150
         $result = $videoTranscoder->transcode_asset(
@@ -224,16 +227,18 @@  discard block
 block discarded – undo
224 227
 
225 228
         if (!file_exists($outputFilesPath))
226 229
         {
227
-            if ($this->debug)
228
-                $this->cpeLogger->logOut("INFO", basename(__FILE__),
230
+            if ($this->debug) {
231
+                            $this->cpeLogger->logOut("INFO", basename(__FILE__),
229 232
                                          "Creating TMP output folder '".$outputFilesPath."'",
230 233
                                          $this->logKey);
234
+            }
231 235
 
232
-            if (!mkdir($outputFilesPath, 0750, true))
233
-                throw new CpeSdk\CpeException(
236
+            if (!mkdir($outputFilesPath, 0750, true)) {
237
+                            throw new CpeSdk\CpeException(
234 238
                     "Unable to create temporary folder '$outputFilesPath' !",
235 239
                     self::TMP_FOLDER_FAIL
236 240
                 );
241
+            }
237 242
         }
238 243
 
239 244
         return ($outputFilesPath);
@@ -302,15 +307,18 @@  discard block
 block discarded – undo
302 307
     global $name;
303 308
 
304 309
     // Handle input parameters
305
-    if (!($options = getopt("N:A:l:C:hd")))
306
-        usage();
310
+    if (!($options = getopt("N:A:l:C:hd"))) {
311
+            usage();
312
+    }
307 313
 
308
-    if (isset($options['h']))
309
-        usage();
314
+    if (isset($options['h'])) {
315
+            usage();
316
+    }
310 317
 
311 318
     // Debug
312
-    if (isset($options['d']))
313
-        $debug = true;
319
+    if (isset($options['d'])) {
320
+            $debug = true;
321
+    }
314 322
 
315 323
     if (isset($options['A']) && $options['A']) {
316 324
         $arn = $options['A'];
@@ -329,9 +337,10 @@  discard block
 block discarded – undo
329 337
         $name = $options['N'];
330 338
     }
331 339
 
332
-    if (isset($options['l']))
333
-        $logPath = $options['l'];
334
-}
340
+    if (isset($options['l'])) {
341
+            $logPath = $options['l'];
342
+    }
343
+    }
335 344
 
336 345
 
337 346
 
Please login to merge, or discard this patch.
src/activities/ValidateAssetActivity.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@
 block discarded – undo
237 237
 
238 238
 $cpeLogger = new SA\CpeSdk\CpeLogger($name, $logPath);
239 239
 $cpeLogger->logOut("INFO", basename(__FILE__),
240
-                   "\033[1mStarting activity\033[0m: $name");
240
+                    "\033[1mStarting activity\033[0m: $name");
241 241
 
242 242
 // We instanciate the Activity 'ValidateAsset' and give it a name for Snf
243 243
 $activityPoller = new ValidateAssetActivity(
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
         static $limit = 1024; // 500 bytes, it's only a test
54 54
         
55 55
         $len = strlen($this->curl_data) + strlen($chunk);
56
-        if ($len >= $limit ) {
57
-            $this->curl_data .= substr($chunk, 0, $limit-strlen($this->curl_data));
56
+        if ($len >= $limit) {
57
+            $this->curl_data .= substr($chunk, 0, $limit - strlen($this->curl_data));
58 58
             return -1;
59 59
         }
60 60
         
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 // Usage
170 170
 function usage()
171 171
 {
172
-    echo("Usage: php ". basename(__FILE__) . " -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
172
+    echo("Usage: php ".basename(__FILE__)." -A <Snf ARN> [-C <client class path>] [-N <activity name>] [-h] [-d] [-l <log path>]\n");
173 173
     echo("-h: Print this help\n");
174 174
     echo("-d: Debug mode\n");
175 175
     echo("-l <log_path>: Location where logs will be dumped in (folder).\n");
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@  discard block
 block discarded – undo
36 36
     public function __construct($client = null, $params, $debug, $cpeLogger)
37 37
     {
38 38
         # Check if preper env vars are setup
39
-        if (!($region = getenv("AWS_DEFAULT_REGION")))
40
-            throw new CpeSdk\CpeException("Set 'AWS_DEFAULT_REGION' environment variable!");
39
+        if (!($region = getenv("AWS_DEFAULT_REGION"))) {
40
+                    throw new CpeSdk\CpeException("Set 'AWS_DEFAULT_REGION' environment variable!");
41
+        }
41 42
         
42 43
         parent::__construct($client, $params, $debug, $cpeLogger);
43 44
         
@@ -86,8 +87,7 @@  discard block
 block discarded – undo
86 87
             curl_exec($ch);
87 88
             curl_close($ch);
88 89
             $chunk = $this->curl_data;
89
-        }
90
-        else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
90
+        } else if (isset($this->input->{'input_asset'}->{'bucket'}) &&
91 91
                  isset($this->input->{'input_asset'}->{'file'})) {
92 92
             // Fetch first 1 KiB of the file for Magic number validation
93 93
             $obj = $this->s3->getObject([
@@ -106,13 +106,14 @@  discard block
 block discarded – undo
106 106
             'file -b --mime-type '.escapeshellarg($tmpFile))['out']);
107 107
         $type = substr($mime, 0, strpos($mime, '/'));
108 108
 
109
-        if ($this->debug)
110
-            $this->cpeLogger->logOut(
109
+        if ($this->debug) {
110
+                    $this->cpeLogger->logOut(
111 111
                 "DEBUG",
112 112
                 basename(__FILE__),
113 113
                 "File meta information gathered. Mime: $mime | Type: $type",
114 114
                 $this->logKey
115 115
         );
116
+        }
116 117
 
117 118
         // Load the right transcoder base on input_type
118 119
         // Get asset detailed info
@@ -190,15 +191,18 @@  discard block
 block discarded – undo
190 191
     global $name;
191 192
     
192 193
     // Handle input parameters
193
-    if (!($options = getopt("N:A:l:C:hd")))
194
-        usage();
194
+    if (!($options = getopt("N:A:l:C:hd"))) {
195
+            usage();
196
+    }
195 197
     
196
-    if (isset($options['h']))
197
-        usage();
198
+    if (isset($options['h'])) {
199
+            usage();
200
+    }
198 201
 
199 202
     // Debug
200
-    if (isset($options['d']))
201
-        $debug = true;
203
+    if (isset($options['d'])) {
204
+            $debug = true;
205
+    }
202 206
 
203 207
     if (isset($options['A']) && $options['A']) {
204 208
         $arn = $options['A'];
@@ -217,9 +221,10 @@  discard block
 block discarded – undo
217 221
         $name = $options['N'];
218 222
     }
219 223
     
220
-    if (isset($options['l']))
221
-        $logPath = $options['l'];
222
-}
224
+    if (isset($options['l'])) {
225
+            $logPath = $options['l'];
226
+    }
227
+    }
223 228
 
224 229
 
225 230
 /*
Please login to merge, or discard this patch.
src/scripts/putInS3.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  * Script used to put a file in AWS S3
5 5
  **/
6 6
 
7
-require __DIR__ . "/../../vendor/autoload.php";
7
+require __DIR__."/../../vendor/autoload.php";
8 8
 
9 9
 function usage()
10 10
 {
11
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
11
+    echo("Usage: php ".basename(__FILE__)." [-h] [--rrs::] [--encrypt::] --bucket <s3 bucket> --file <filename> --from <filepath>\n");
12 12
     echo("--help, -h: Print this help\n");
13 13
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
14 14
     echo("--file <filename>: Name of the file to create in bucket. You can override local filename.\n");
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         usage();
32 32
     }
33 33
 
34
-    $options['bucket'] = rtrim( $options['bucket'], "/");
34
+    $options['bucket'] = rtrim($options['bucket'], "/");
35 35
 }
36 36
 
37 37
 $options = getopt("h", [
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
     $s3->putObject($params); 
72 72
     
73 73
     // Print JSON error output
74
-    print json_encode([ "status" => "SUCCESS",
75
-            "msg" => "[".__FILE__."] Upload '" . $options['from'] . "' to '" . $options['bucket'] . "/" . $options['file']  . "' successful !" ]);
74
+    print json_encode(["status" => "SUCCESS",
75
+            "msg" => "[".__FILE__."] Upload '".$options['from']."' to '".$options['bucket']."/".$options['file']."' successful !"]);
76 76
 } 
77 77
 catch (Exception $e) {
78
-    $err = "Unable to put file '" . $options['from']  . "' into S3: '" . $options['bucket'] . "/" . $options['file']  . "'! " . $e->getMessage();
78
+    $err = "Unable to put file '".$options['from']."' into S3: '".$options['bucket']."/".$options['file']."'! ".$e->getMessage();
79 79
     
80 80
     // Print JSON error output
81
-    print json_encode([ "status" => "ERROR",
82
-            "msg" => "[".__FILE__."] $err" ]);
81
+    print json_encode(["status" => "ERROR",
82
+            "msg" => "[".__FILE__."] $err"]);
83 83
 
84 84
     die("[".__FILE__."] $err");
85 85
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
 function check_input_parameters(&$options)
22 22
 {
23 23
     if (!count($options) || isset($options['h']) ||
24
-        isset($options['help']))
25
-        usage();
24
+        isset($options['help'])) {
25
+            usage();
26
+    }
26 27
     
27 28
     if (!isset($options['bucket']) || !isset($options['file']) ||
28 29
         !isset($options['from']))
@@ -46,8 +47,9 @@  discard block
 block discarded – undo
46 47
 
47 48
 try {
48 49
     # Check if preper env vars are setup
49
-    if (!($region = getenv("AWS_DEFAULT_REGION")))
50
-        throw new CpeSdk\CpeException("Set 'AWS_DEFAULT_REGION' environment variable!");
50
+    if (!($region = getenv("AWS_DEFAULT_REGION"))) {
51
+            throw new CpeSdk\CpeException("Set 'AWS_DEFAULT_REGION' environment variable!");
52
+    }
51 53
         
52 54
     // Get S3 client
53 55
     $s3 = new \Aws\S3\S3Client([
@@ -62,10 +64,12 @@  discard block
 block discarded – undo
62 64
     );
63 65
 
64 66
     // StorageClass and Encryption ?
65
-    if (isset($options['rrs']))
66
-        $params['StorageClass'] = 'REDUCED_REDUNDANCY';
67
-    if (isset($options['encrypt']))
68
-        $params['ServerSideEncryption'] = 'AES256';
67
+    if (isset($options['rrs'])) {
68
+            $params['StorageClass'] = 'REDUCED_REDUNDANCY';
69
+    }
70
+    if (isset($options['encrypt'])) {
71
+            $params['ServerSideEncryption'] = 'AES256';
72
+    }
69 73
     
70 74
     // Upload and Save file to S3
71 75
     $s3->putObject($params); 
@@ -73,8 +77,7 @@  discard block
 block discarded – undo
73 77
     // Print JSON error output
74 78
     print json_encode([ "status" => "SUCCESS",
75 79
             "msg" => "[".__FILE__."] Upload '" . $options['from'] . "' to '" . $options['bucket'] . "/" . $options['file']  . "' successful !" ]);
76
-} 
77
-catch (Exception $e) {
80
+} catch (Exception $e) {
78 81
     $err = "Unable to put file '" . $options['from']  . "' into S3: '" . $options['bucket'] . "/" . $options['file']  . "'! " . $e->getMessage();
79 82
     
80 83
     // Print JSON error output
Please login to merge, or discard this patch.
src/scripts/getFromS3.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     filesize($options['to']))
38 38
 {
39 39
     $out = [ "status" => "SUCCESS",
40
-             "msg" => "[".__FILE__."] Using local copy: '" . $options['to']  . "'" ];
40
+                "msg" => "[".__FILE__."] Using local copy: '" . $options['to']  . "'" ];
41 41
     print json_encode($out)."\n";
42 42
     exit(0);
43 43
 }
@@ -60,6 +60,6 @@  discard block
 block discarded – undo
60 60
 ));
61 61
 
62 62
 $out = [ "status" => "SUCCESS",
63
-         "msg" => "[".__FILE__."] Download '" . $options['bucket'] . "/" . $options['file'] . "' successful !" ];
63
+            "msg" => "[".__FILE__."] Download '" . $options['bucket'] . "/" . $options['file'] . "' successful !" ];
64 64
 
65 65
 print json_encode($out)."\n";
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  * Script used to get a file in AWS S3
5 5
  **/
6 6
 
7
-require __DIR__ . "/../../vendor/autoload.php";
7
+require __DIR__."/../../vendor/autoload.php";
8 8
 
9 9
 function usage()
10 10
 {
11
-    echo("Usage: php ". basename(__FILE__) . " [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
11
+    echo("Usage: php ".basename(__FILE__)." [-h] [--force] --bucket <s3 bucket> --file <filename> --to <filepath>\n");
12 12
     echo("--help, -h: Print this help\n");
13 13
     echo("--bucket <s3 bucket>: Name of the S3 bucket\n");
14 14
     echo("--file <filename>: Name of the file in the S3 bucket\n");
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
     file_exists($options['to']) &&
37 37
     filesize($options['to']))
38 38
 {
39
-    $out = [ "status" => "SUCCESS",
40
-             "msg" => "[".__FILE__."] Using local copy: '" . $options['to']  . "'" ];
39
+    $out = ["status" => "SUCCESS",
40
+             "msg" => "[".__FILE__."] Using local copy: '".$options['to']."'"];
41 41
     print json_encode($out)."\n";
42 42
     exit(0);
43 43
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     'SaveAs' => $options['to']
60 60
 ));
61 61
 
62
-$out = [ "status" => "SUCCESS",
63
-         "msg" => "[".__FILE__."] Download '" . $options['bucket'] . "/" . $options['file'] . "' successful !" ];
62
+$out = ["status" => "SUCCESS",
63
+         "msg" => "[".__FILE__."] Download '".$options['bucket']."/".$options['file']."' successful !"];
64 64
 
65 65
 print json_encode($out)."\n";
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,13 +20,15 @@  discard block
 block discarded – undo
20 20
 function check_input_parameters($options)
21 21
 {
22 22
     if (!count($options) || isset($options['h']) ||
23
-        isset($options['help']))
24
-        usage();
23
+        isset($options['help'])) {
24
+            usage();
25
+    }
25 26
 
26 27
     if (!isset($options['bucket']) || !isset($options['file']) ||
27
-        !isset($options['to']))
28
-        throw new \SA\CpeSdk\CpeException("Missing mandatory parameter!");
29
-}
28
+        !isset($options['to'])) {
29
+            throw new \SA\CpeSdk\CpeException("Missing mandatory parameter!");
30
+    }
31
+    }
30 32
 
31 33
 $options = getopt("h", array("bucket:", "file:", "to:", "force::", "help::"));
32 34
 check_input_parameters($options);
@@ -43,8 +45,9 @@  discard block
 block discarded – undo
43 45
 }
44 46
 
45 47
 # Check if preper env vars are setup
46
-if (!($region = getenv("AWS_DEFAULT_REGION")))
48
+if (!($region = getenv("AWS_DEFAULT_REGION"))) {
47 49
     throw new \SA\CpeSdk\CpeException("Set 'AWS_DEFAULT_REGION' environment variable!");
50
+}
48 51
 
49 52
 // Get S3 client
50 53
 $s3 = new \Aws\S3\S3Client([
Please login to merge, or discard this patch.