Adding Object::enum()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4495 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-02-10 08:13:28 +00:00
parent 96abdcb619
commit 2c837ffac2

View file

@ -74,6 +74,22 @@ class Object{
$class = get_class($this);
return $class;
}
/**
* Return a value from an array list.
*
* @param string $selected
* @param array $list
* @return string the value of the array key
*/
function enum($select, $list = array('no', 'yes')) {
$return = null;
if(is_array($list)){
if (array_key_exists($select, $list)) {
$return = $list[$select];
}
}
return $return;
}
/**
* Calls a controller's method from any location.
*