Example #1
0
 public function vary($featureName, array $context = array())
 {
     $strategy = $this->registry->resolveStrategy($featureName);
     $feature = $this->registry->getFeature($featureName);
     if (!$strategy) {
         throw new \RuntimeException(sprintf("No strategy was found for feature '%s'.", $featureName));
     }
     if ($userKey = $this->getUserKey() && ($result = $this->memoryAdapter->get($feature, $userKey))) {
         return $result;
     } else {
         $userKey = $this->getUserKey();
         $result = $this->decider->decide($strategy, $feature, $context);
         if ($userKey) {
             $this->memoryAdapter->save($feature, $userKey, $result);
         }
     }
     return $result;
 }