class composition instead of object composition?

Posted by fayer on Stack Overflow See other posts from Stack Overflow or by fayer
Published on 2010-05-06T15:03:47Z Indexed on 2010/05/06 15:08 UTC
Read the original article Hit count: 371

Filed under:
|

I want a class property to be reference to another class, not its object and then use this property to call the class's static methods.

class Database { private static $log;

public static function addLog($LogClass) {
    self::$log = $LogClass;
}

public static function log() {
    self::$log::write(); // seems not possible to write it like this
}

}

any suggestions how i can accomplish this?

cause i have no reason making them objects, i want to use the classes for it.

© Stack Overflow or respective owner

Related posts about oop

Related posts about php