refactor(migrasi): optimalkan import dan reorganisasi method __call

- Refactor import `Jobs` menggunakan sintaks kurung kurawal untuk mengurangi redundansi dan meningkatkan keterbacaan kode.
- Pindahkan metode `__call` di atas `processData` untuk memperbaiki struktur kode sehingga lebih terorganisir.
- Atur ulang logika dalam `__call` tanpa mengubah fungsionalitas utama tetapi memperbaiki posisi metode dalam kelas.
- Hilangkan duplikasi metode `__call` dengan memindahkannya ke lokasi baru.

Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
Daeng Deni Mardaeni
2025-05-26 15:49:00 +07:00
parent c6363473ac
commit 9025663954

View File

@@ -3,25 +3,26 @@
namespace Modules\Webstatement\Http\Controllers; namespace Modules\Webstatement\Http\Controllers;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use BadMethodCallException;
use Exception; use Exception;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Log; use Log;
use Modules\Webstatement\Jobs\ProcessAccountDataJob; use Modules\Webstatement\Jobs\{ProcessAccountDataJob,
use Modules\Webstatement\Jobs\ProcessArrangementDataJob; ProcessArrangementDataJob,
use Modules\Webstatement\Jobs\ProcessAtmTransactionJob; ProcessAtmTransactionJob,
use Modules\Webstatement\Jobs\ProcessBillDetailDataJob; ProcessBillDetailDataJob,
use Modules\Webstatement\Jobs\ProcessCategoryDataJob; ProcessCategoryDataJob,
use Modules\Webstatement\Jobs\ProcessCompanyDataJob; ProcessCompanyDataJob,
use Modules\Webstatement\Jobs\ProcessCustomerDataJob; ProcessCustomerDataJob,
use Modules\Webstatement\Jobs\ProcessDataCaptureDataJob; ProcessDataCaptureDataJob,
use Modules\Webstatement\Jobs\ProcessFtTxnTypeConditionJob; ProcessFtTxnTypeConditionJob,
use Modules\Webstatement\Jobs\ProcessFundsTransferDataJob; ProcessFundsTransferDataJob,
use Modules\Webstatement\Jobs\ProcessStmtEntryDataJob; ProcessStmtEntryDataJob,
use Modules\Webstatement\Jobs\ProcessStmtNarrFormatDataJob; ProcessStmtNarrFormatDataJob,
use Modules\Webstatement\Jobs\ProcessStmtNarrParamDataJob; ProcessStmtNarrParamDataJob,
use Modules\Webstatement\Jobs\ProcessTellerDataJob; ProcessTellerDataJob,
use Modules\Webstatement\Jobs\ProcessTransactionDataJob; ProcessTransactionDataJob};
class MigrasiController extends Controller class MigrasiController extends Controller
{ {
@@ -64,6 +65,17 @@
'billDetail' 'billDetail'
]; ];
public function __call($method, $parameters)
{
if (strpos($method, 'process') === 0) {
$type = lcfirst(substr($method, 7));
if (isset(self::PROCESS_TYPES[$type])) {
return $this->processData($type, $parameters[0] ?? '');
}
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
private function processData(string $type, string $period) private function processData(string $type, string $period)
: JsonResponse : JsonResponse
{ {
@@ -81,17 +93,6 @@
} }
} }
public function __call($method, $parameters)
{
if (strpos($method, 'process') === 0) {
$type = lcfirst(substr($method, 7));
if (isset(self::PROCESS_TYPES[$type])) {
return $this->processData($type, $parameters[0] ?? '');
}
}
throw new BadMethodCallException("Method {$method} does not exist.");
}
public function index() public function index()
{ {
$disk = Storage::disk('sftpStatement'); $disk = Storage::disk('sftpStatement');