Since you're seemingly only interested in one specific method/function (without further contracts/interfaces) you can write the code in a way that it doesn't matter whether it's a static method or an object method (...hm, object method...that doesn't sound right, what's the right name...) or a simple function.
class LogDummy {
public static function write($s) {
echo 'LogDummy::write: ', $s, "\n";
}
public function writeMe($s) {
echo 'LogDummy->writeMe: ', $s, "\n";
}
}
class Database {
private static $log=null;
public static function setLog($fnLog) {
self::$log = $fnLog;
}
public static function log($s) {
call_user_func_array(self::$log, array($s));
}
}
// static method
Database::setLog(array('LogDummy', 'write'));
Database::log('foo');
// member method
$l = new LogDummy;
Database::setLog(array($l, 'writeMe'));
Database::log('bar');
// plain old function
function dummylog($s) {
echo 'dummylog: ', $s, "\n";
}
Database::setLog('dummylog');
Database::log('baz');
// anonymous function
Database::setLog( function($s) {
echo 'anonymous: ', $s, "\n";
} );
Database::log('ham');
prints
LogDummy::write: foo
LogDummy->writeMe: bar
dummylog: baz
anonymous: ham