Skip to content

Commit

Permalink
Singleton instance must depend on requested token
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-yantsen committed Feb 5, 2016
1 parent b89318b commit d50267c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Mixpanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class Mixpanel extends Base_MixpanelBase {


/**
* An instance of the Mixpanel class (for singleton use)
* @var Mixpanel
* Instances' list of the Mixpanel class (for singleton use, splitted by token)
* @var Mixpanel[]
*/
private static $_instance;
private static $_instances = array();


/**
Expand All @@ -149,10 +149,10 @@ public function __construct($token, $options = array()) {
* @return Mixpanel
*/
public static function getInstance($token, $options = array()) {
if(!isset(self::$_instance)) {
self::$_instance = new Mixpanel($token, $options);
if(!isset(self::$_instances[$token])) {
self::$_instances[$token] = new Mixpanel($token, $options);
}
return self::$_instance;
return self::$_instances[$token];
}


Expand Down

0 comments on commit d50267c

Please sign in to comment.