2024-05-09 20:25:56 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description of ModelTraits
|
|
|
|
*
|
2024-05-15 14:54:33 -05:00
|
|
|
* @author Mike Howard
|
2024-05-09 20:25:56 -05:00
|
|
|
*/
|
2024-05-13 14:36:49 -05:00
|
|
|
trait ModelTraits {
|
2024-05-09 20:25:56 -05:00
|
|
|
private $params = array();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @assert ('name', 'value')
|
|
|
|
*/
|
|
|
|
public function __set($name, $value)
|
|
|
|
{
|
|
|
|
//echo "Setting '$name' to '$value'\n";
|
|
|
|
$this->params[$name] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @assert ('name') == 'value'
|
|
|
|
*/
|
|
|
|
public function __get($name)
|
|
|
|
{
|
|
|
|
//echo "Getting '$name'\n";
|
|
|
|
if (array_key_exists($name, $this->params)) {
|
|
|
|
return $this->params[$name];
|
|
|
|
}
|
|
|
|
|
|
|
|
$trace = debug_backtrace();
|
|
|
|
trigger_error(
|
|
|
|
'Undefined property via __get(): ' . $name .
|
|
|
|
' in ' . $trace[0]['file'] .
|
|
|
|
' on line ' . $trace[0]['line'],
|
|
|
|
E_USER_NOTICE);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @assert ('name') == 'true'
|
|
|
|
* @assert ('test') == 'false'
|
|
|
|
*/
|
|
|
|
public function __isset($name)
|
|
|
|
{
|
|
|
|
//echo "Is '$name' set?\n";
|
|
|
|
return isset($this->params[$name]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __unset($name)
|
|
|
|
{
|
|
|
|
//echo "Unsetting '$name'\n";
|
|
|
|
unset($this->params[$name]);
|
|
|
|
}
|
|
|
|
}
|