Skip to content

PHP Object Baseclass

Michael edited this page Aug 19, 2015 · 1 revision

Why should I use the object baseclass?

The object baseclass allows to have more readable classname access which is indifferent of name changes.

Any place where a class name is required one can use the method instead of String constant:

without object baseclass:

    ...
    usort($data, '\Fossology\Lib\Foo', 'dataSorter'));
    ...

with object baseclass:

    ...
    usort($data, array($this->classname(), 'dataSorter'));
    ...

If method known from other languages / newer php versions like equals() or hashcode() are required the can be implemented in the object baseclass as well.

How to use the object baseclass

Just extend the object baseclass from your class:

use Fossology\Lib\Util\Object;

class Foo extends Object {

}
Clone this wiki locally