trait TSingleton {
private static $_instance = null;
public static function getInstance() {
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
}
class FrontController {
use TSingleton;
}
class WebSite extends SomeClass {
use TSingleton;
}
trait TBounding {
public $x, $y, $width, $height;
}
trait TMoveable {
public function moveTo($x, $y) {
// ...
}
}
trait TResizeable {
public function resize($newWidth, $newHeight) {
// ...
}
}
class Rectangle {
use TBounding, TMoveable, TResizeable;
public function fillColor($color) {
// ...
}
}