<?php
require_once 'ite/structs/Singletone.php';
use ite\structs\Singletone;
class MySingletoneClass {
use Singletone;
public function myMethod() {
return 'Singletone trait example';
}
}
try {
$MySingletoneObject = MySingletoneClass::getInstance();
echo $MySingletoneObject->myMethod();
$object = $MySingletoneObject();
var_dump($object === $MySingletoneObject);
$str = serialize($MySingletoneObject);
}
catch (RuntimeException $e) {
try {
$object = clone $MySingletoneObject
}
catch (RuntimeException $ee) {
die($e->getMessage().'<br />'.$ee->getMessage());
}
die($e->getMessage());
}
?>
|