I have function that has three parameters, called key
, value
and attribute
.
Parameter attribute
may be empty or have within two arguments. Code of function below is shortened (deprived of arguments validation)
public function Set_ContentUsage($Key, $Value, $Attribute=NULL)
{
$this -> ContentUsage = array();
$Attribute = array_slice(func_get_args(), 2);
/* validation of arguments */
$this -> ContentUsage['key'] = $Key;
$this -> ContentUsage['value'] = $Value;
if(count($Attribute) == 1)
{
$this -> ContentUsage['keyattr'] = ($Key == MarC::MARC_OPTION_ATTRVAL) ? $Attribute[0] : FALSE;
$this -> ContentUsage['valueattr'] = ($Value == MarC::MARC_OPTION_ATTRVAL) ? $Attribute[0] : FALSE;
}
else
{
$this -> ContentUsage['keyattr'] = $Attribute[0];
$this -> ContentUsage['valueattr'] = $Attribute[1];
}
}
My question is how to get multiple arguments for last parameter in better way? in cases like this.