refactor(jobs): improve flexibility in periods parameter handling

- Mengubah tipe properti `periods` dari `protected $periods` menjadi `protected array $periods` untuk memastikan konsistensi tipe data.
- Memodifikasi konstruktor pada beberapa job class (`ProcessFtTxnTypeConditionJob`, `ProcessStmtNarrFormatDataJob`, `ProcessStmtNarrParamDataJob`, dan `ProcessTransactionDataJob`) agar mendukung parameter `periods` dalam bentuk array atau string.
- Menambahkan validasi dalam konstruktor untuk mengonversi string `periods` menjadi array jika diperlukan, memastikan fleksibilitas dan kompatibilitas yang lebih baik saat inisialisasi object.
- Refaktor ini meningkatkan kejelasan dalam codebase dan mengurangi potensi error akibat perbedaan format input.
This commit is contained in:
daengdeni
2025-05-26 13:47:52 +07:00
parent 1e1120d29b
commit 41ed7c1ed9
4 changed files with 16 additions and 13 deletions

View File

@@ -16,18 +16,18 @@ class ProcessFtTxnTypeConditionJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods;
protected $filename; protected $filename;
protected array $periods;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(array $periods = [], string $filename = "ST.FT.TXN.TYPE.CONDITION.csv") public function __construct(array|string $periods = [])
{ {
$this->periods = $periods; $this->periods = is_string($periods) ? [$periods] : $periods;
$this->filename = $filename;
} }
/** /**
* Execute the job. * Execute the job.
*/ */

View File

@@ -16,16 +16,17 @@ class ProcessStmtNarrFormatDataJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods; protected array $periods;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(array $periods = []) public function __construct(array|string $periods = [])
{ {
$this->periods = $periods; $this->periods = is_string($periods) ? [$periods] : $periods;
} }
/** /**
* Execute the job. * Execute the job.
*/ */

View File

@@ -16,16 +16,17 @@
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods; protected array $periods;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(array $periods = []) public function __construct(array|string $periods = [])
{ {
$this->periods = $periods; $this->periods = is_string($periods) ? [$periods] : $periods;
} }
/** /**
* Execute the job. * Execute the job.
*/ */

View File

@@ -16,16 +16,17 @@ class ProcessTransactionDataJob implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $periods; protected array $periods;
/** /**
* Create a new job instance. * Create a new job instance.
*/ */
public function __construct(array $periods = []) public function __construct(array|string $periods = [])
{ {
$this->periods = $periods; $this->periods = is_string($periods) ? [$periods] : $periods;
} }
/** /**
* Execute the job. * Execute the job.
*/ */