<?php
$dir = 'app/Controllers/';
$files = glob($dir . '*.php');

$replacements = [
    "->where('pengaturan_key', 'pddikti_url')->first()['pengaturan_value']" => "->getValue('pddikti_url', '')",
    "->where('pengaturan_key', 'pddikti_username')->first()['pengaturan_value']" => "->getValue('pddikti_username', '')",
    "->where('pengaturan_key', 'pddikti_password')->first()['pengaturan_value']" => "->getValue('pddikti_password', '')"
];

foreach ($files as $file) {
    $content = file_get_contents($file);
    $new_content = str_replace(array_keys($replacements), array_values($replacements), $content);
    if ($content !== $new_content) {
        file_put_contents($file, $new_content);
        echo basename($file) . " updated.\n";
    }
}
echo "Done.\n";
