Skip to content

Instantly share code, notes, and snippets.

@lloc
Created October 1, 2011 15:27
Show Gist options
  • Save lloc/1256180 to your computer and use it in GitHub Desktop.
Save lloc/1256180 to your computer and use it in GitHub Desktop.
slotObject in PHP
<?php
class slotObject {
function set ($input) {
$slot = array_keys (get_class_vars (get_class ($this)));
if (is_array ($input)) {
foreach ($input as $key => $value) {
if (in_array ($key, $slot)) {
$this->$key = $value;
}
else {
die ("AttributeError: '" . get_class ($this) . "' object has no attribute '" . $key . "'");
}
}
}
}
}
?>
@lloc
Copy link
Author

lloc commented Oct 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment