Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
12 | use Illuminate\Support\Facades\Log; |
||
13 | |||
14 | class S3Upload implements ShouldQueue |
||
15 | { |
||
16 | use Dispatchable, |
||
17 | InteractsWithQueue, |
||
18 | Queueable, |
||
19 | SerializesModels, |
||
20 | SavesToAmazonS3; |
||
21 | |||
22 | public bool $deleteWhenMissingModels = true; |
||
|
|||
23 | protected News $article; |
||
24 | |||
25 | /** |
||
26 | * Create a new job instance. |
||
27 | * |
||
28 | * @param News $article |
||
29 | */ |
||
30 | public function __construct(News $article) |
||
31 | { |
||
32 | $this->article = $article; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Execute the job. |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
49 |