config = $config; $this->user = $user; } /** * @inheritDoc */ public function getName() : string { return Constants::REQUIREMENT_SEARCH_IN_HEADER; } /** * If A/B test is enabled check whether the user is logged in and bucketed * @return bool */ private function isBucketed() { $isABTestEnabled = (bool)$this->config->get( Constants::CONFIG_SEARCH_IN_HEADER_AB ); if ( $isABTestEnabled ) { return $this->user->getId() % 2 === 0; } else { // if A/B test is disabled then resort to using CONFIG_SEARCH_IN_HEADER return (bool)$this->config->get( Constants::CONFIG_SEARCH_IN_HEADER ); } } /** * @inheritDoc * @throws \ConfigException */ public function isMet() : bool { return $this->user->isRegistered() ? $this->isBucketed() : (bool)$this->config->get( Constants::CONFIG_SEARCH_IN_HEADER ); } }