/**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Check if trial is available for current user.
  *
  * @return boolean
  */
 public function trialAvailable()
 {
     $result = true;
     // return cached version
     if (!is_null($this->cached_trial_available)) {
         return $this->cached_trial_available;
     }
     // prepare variables for processing
     $address = $_SERVER['REMOTE_ADDR'];
     $manager = SapphireWavesTrialManager::getInstance();
     // remove old entries
     $manager->deleteData(array('timestamp' => array('operator' => '<', 'value' => time() - 7 * 24 * 60 * 60)));
     // check if we have existing records
     $record = $manager->getSingleItem($manager->getFieldNames(), array('address' => $address));
     if (is_object($record)) {
         $result = $record->timestamp >= time() - 7 * 24 * 60 * 60 && $record->times_used <= 2;
     }
     // cache result for further use in current execution
     $this->cached_trial_available = $result;
     return $result;
 }