/** * @param string $key * @param \SplitIO\Grammar\Split $split * @return null|string */ public static function getTreatment($matchingKey, $bucketingKey, SplitGrammar $split, array $attributes = null) { $conditions = $split->getConditions(); foreach ($conditions as $condition) { if ($condition->match($matchingKey, $attributes)) { return Splitter::getTreatment($bucketingKey, $split->getSeed(), $condition->getPartitions()); } } return null; }
/** * @param $splitCacheKey * @return null|SplitView */ private function getSplitByCacheKey($splitCacheKey) { $splitCachedItem = SplitApp::cache()->getItem($splitCacheKey); if ($splitCachedItem->isHit()) { $splitRepresentation = $splitCachedItem->get(); $split = new Split(json_decode($splitRepresentation, true)); return new SplitView($split->getName(), $split->getTrafficTypeName(), $split->killed(), $split->getTreatments(), $split->getChangeNumber()); } return null; }