1 | <?php |
||
2 | |||
3 | namespace Meema\MediaConverter\Jobs; |
||
4 | |||
5 | use Illuminate\Bus\Queueable; |
||
6 | use Illuminate\Contracts\Queue\ShouldQueue; |
||
7 | use Illuminate\Foundation\Bus\Dispatchable; |
||
8 | use Illuminate\Queue\InteractsWithQueue; |
||
9 | use Illuminate\Queue\SerializesModels; |
||
10 | use Meema\MediaConverter\Facades\MediaConvert; |
||
11 | |||
12 | class CreateVideoConversion implements ShouldQueue |
||
13 | { |
||
14 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private array $jobSettings; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private int $mediaId; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private array $tags; |
||
30 | |||
31 | /** |
||
32 | * Create a new job instance. |
||
33 | * |
||
34 | * @param array $jobSettings |
||
35 | * @param array $tags |
||
36 | * @param int $mediaId |
||
37 | */ |
||
38 | public function __construct($jobSettings, $tags = [], $mediaId = null) |
||
39 | { |
||
40 | $this->jobSettings = $jobSettings; |
||
41 | $this->tags = $tags; |
||
42 | |||
43 | if ($mediaId) { |
||
0 ignored issues
–
show
The expression
$mediaId of type integer|null is loosely compared to true ; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For 0 == false // true
0 == null // true
123 == false // false
123 == null // false
// It is often better to use strict comparison
0 === false // false
0 === null // false
![]() |
|||
44 | $this->mediaId = $mediaId; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Execute the job. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function handle() |
||
54 | { |
||
55 | $metaData = []; |
||
56 | $tags = $this->tags; |
||
57 | |||
58 | if ($this->mediaId) { |
||
59 | $metaData = ['model_id' => $this->mediaId]; |
||
60 | } |
||
61 | |||
62 | MediaConvert::createJob($this->jobSettings, $metaData, $tags); |
||
63 | } |
||
64 | } |
||
65 |