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;
use App\Http\Controllers\Controller;
use BadMethodCallException;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Storage;
use Log;
use Modules\Webstatement\Jobs\ProcessAccountDataJob;
use Modules\Webstatement\Jobs\ProcessArrangementDataJob;
use Modules\Webstatement\Jobs\ProcessAtmTransactionJob;
use Modules\Webstatement\Jobs\ProcessBillDetailDataJob;
use Modules\Webstatement\Jobs\ProcessCategoryDataJob;
use Modules\Webstatement\Jobs\ProcessCompanyDataJob;
use Modules\Webstatement\Jobs\ProcessCustomerDataJob;
use Modules\Webstatement\Jobs\ProcessDataCaptureDataJob;
use Modules\Webstatement\Jobs\ProcessFtTxnTypeConditionJob;
use Modules\Webstatement\Jobs\ProcessFundsTransferDataJob;
use Modules\Webstatement\Jobs\ProcessStmtEntryDataJob;
use Modules\Webstatement\Jobs\ProcessStmtNarrFormatDataJob;
use Modules\Webstatement\Jobs\ProcessStmtNarrParamDataJob;
use Modules\Webstatement\Jobs\ProcessTellerDataJob;
use Modules\Webstatement\Jobs\ProcessTransactionDataJob;
use Modules\Webstatement\Jobs\{ProcessAccountDataJob,
ProcessArrangementDataJob,
ProcessAtmTransactionJob,
ProcessBillDetailDataJob,
ProcessCategoryDataJob,
ProcessCompanyDataJob,
ProcessCustomerDataJob,
ProcessDataCaptureDataJob,
ProcessFtTxnTypeConditionJob,
ProcessFundsTransferDataJob,
ProcessStmtEntryDataJob,
ProcessStmtNarrFormatDataJob,
ProcessStmtNarrParamDataJob,
ProcessTellerDataJob,
ProcessTransactionDataJob};
class MigrasiController extends Controller
{
@@ -64,6 +65,17 @@
'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)
: 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()
{
$disk = Storage::disk('sftpStatement');