public hasNoEntry ( string $key ) : void | ||
$key | string | key The key to look for inside the tableName table |
return | void |
public function hasNoEntry($key)
{
// get our table name from the constructor
$tableName = $this->args[0];
// what are we doing?
$log = usingLog()->startAction("make sure there is no existing entry for '{$key}' in '{$tableName}'");
// get the table config
$tables = $this->getAllTables();
// make sure we have a hosts table
if (!isset($tables->{$tableName})) {
$msg = "table is empty / does not exist";
$log->endAction($msg);
return;
}
// make sure we don't have a duplicate entry
if (isset($tables->{$tableName}->{$key})) {
$msg = "table already contains an entry for '{$key}'";
$log->endAction($msg);
throw new E5xx_ExpectFailed(__METHOD__, "{$tableName} table has no entry for '{$key}'", "{$parent} table has an entry for '{$key}'");
}
// all done
$log->endAction();
}