I am trying to come up with a way to be able to make any (or at least a group of) class have the ability to have options.
This is the generic interface that I would like to have
interface OptionableInterface
{
public function getOption($key);
public function setOption($key, $value);
public function getOptions();
public function setOptions($options, $merge);
public function removeOption($key);
}
I've thought about either implementing a concrete class with the above interface then extending it as needed, but since PHP has no multiple inheritance, this could be a problem.
The other way would be to use the decorator pattern. But I'm uncertain if this is the correct usage of decorator pattern.
Any ideas? I'm stuck using PHP 5.2 for now (maybe able to change to 5.3 later in which case I can use traits).