class Api_X_Y {
private $_id;
private $_blah_title;
private $_XXXX;
private static $inputParam;
if($inputParam){
}
// Store the single instance of Api_X_Y
private static $Instance;
// Private constructor to limit object instantiation to within the class
private function __construct($id)
{
echo "Test <br />\n";
}
// Getter method for creating/returning the single instance of this class
public static function getInstance($id)
{
if (!self::$Instance)
{
self::$Instance = new self($id);
}
return self::$Instance;
}
public function resetInstance()
{
$this -> _id =NULL;
$this -> _blah_title =NULL;
$this -> _XXXX = NULL;
}
}
?>
Ok I would like to modify the code so that when a new object with a new id comes in, it gets compared with inputParam( which is the ID of the old object), and if it is not the same it gets reset of the properties (public function resetInstance).
I’ve started by inserting the public function resetInstance and I know that I have to implement an IF statement somehow…..
Can anyone help me out?
You want a singleton, but you want it to return a new class when an ID differs. What’s the use of a singleton here?