Prose\UsingRuntimeTableForTargetEnvironment::removeItem PHP Метод

removeItem() публичный Метод

Removes an item from the runtimeConfig file
public removeItem ( string $key ) : void
$key string The key that we want to remove
Результат void
    public function removeItem($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 '{$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. '{$key}' not removed";
            $log->endAction($msg);
            return;
        }
        if (!isset($tables->{$tableName}->{$targetEnv})) {
            $msg = "table for {$targetEnv} is empty / does not exist. '{$key}' not removed";
            $log->endAction($msg);
            return;
        }
        // make sure we have an entry to remove
        if (!isset($tables->{$tableName}->{$targetEnv}->{$key})) {
            $msg = "table does not contain an entry for '{$key}'";
            $log->endAction($msg);
            return;
        }
        // remove the entry
        unset($tables->{$tableName}->{$targetEnv}->{$key});
        // save the changes
        $this->st->saveRuntimeConfig();
        // all done
        $log->endAction();
    }