Prose\UsingRuntimeTableForTargetEnvironment::removeItemFromGroup PHP Method

removeItemFromGroup() public method

Removes an item from the runtimeConfig file
public removeItemFromGroup ( $group, string $key ) : void
$key string The key that we want to remove
return void
    public function removeItemFromGroup($group, $key)
    {
        // get our table name from the constructor
        $tableName = $this->args[0];
        $targetEnv = $this->st->getTestEnvironmentName();
        // what are we doing?
        $log = usingLog()->startAction("remove entry '{$group}->{$key}' from {$tableName}->{$targetEnv} table");
        // get the table config
        $tables = $this->getAllTables();
        // make sure it exists
        if (!isset($tables->{$tableName})) {
            $msg = "table is empty / does not exist. '{$group}->{$key}' not removed";
            $log->endAction($msg);
            return;
        }
        if (!isset($tables->{$tableName}->{$targetEnv})) {
            $msg = "table has no data for '{$targetEnv}'. '{$group}->{$key}' not removed";
            $log->endAction($msg);
            return;
        }
        if (!isset($tables->{$tableName}->{$targetEnv}->{$group})) {
            $msg = "table has no group '{$group}'. '{$group}->{$key}' not removed";
            $log->endAction($msg);
            return;
        }
        if (!isset($tables->{$tableName}->{$group}->{$targetEnv}->{$key})) {
            $msg = "table does not contain an entry for '{$group}->{$key}'";
            $log->endAction($msg);
            return;
        }
        // remove the entry
        unset($tables->{$tableName}->{$targetEnv}->{$group}->{$key});
        // save the changes
        $this->st->saveRuntimeConfig();
        // all done
        $log->endAction();
    }