config = $config; $this->user = $user; $this->name = $name; $this->experimentName = $experimentName; } /** * @inheritDoc */ public function getName(): string { return $this->name; } /** * Returns true if the user is logged-in and false otherwise. * * @inheritDoc */ public function isMet(): bool { // Get the experiment configuration from the config object. $experiment = $this->config->get( 'VectorWebABTestEnrollment' ); // Check if the experiment is not enabled or does not match the specified name. if ( !$experiment['enabled'] || $experiment['name'] !== $this->experimentName ) { // If the experiment is not enabled or does not match the specified name, // return true, indicating that the metric is "met" return true; } else { // If the experiment is enabled and matches the specified name, // calculate the user's variant based on their ID $variant = $this->user->getID() % 2; // Cast the variant value to a boolean and return it, indicating whether // the user is in the "control" or "test" group. return (bool)$variant; } } }