summaryrefslogtreecommitdiffstats
path: root/app/class/table.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/table.class.php')
-rw-r--r--app/class/table.class.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/class/table.class.php b/app/class/table.class.php
index 2759176..45be8c5 100644
--- a/app/class/table.class.php
+++ b/app/class/table.class.php
@@ -201,6 +201,21 @@ abstract class table
while (self::isGUID($guid));
return $guid;
}
+
+ /*
+ * Assert that this object is of the expected type in the database.
+ * Throw an exception if a type mismatch exists. Check will only
+ * be performed if guid and objtype are set on this object.
+ */
+ protected function expectType(string $objtype) : void
+ {
+ if (isset($this->guid) && isset($this->objtype))
+ {
+ if ($this->objtype != $objtype)
+ throw new Exception("Invalid object allocation. " . $this->guid . " is a " .
+ $this->objtype . ", not a " . $objtype . ".");
+ }
+ }
}
?>