Source of file ABTestingExtension.php
Size: 0,988 Bytes - Last Modified: 2021-12-24T06:50:53+00:00
/var/www/docs.ssmods.com/process/src/code/ABTestingExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php /** * Class ABTestingExtension */ class ABTestingExtension extends DataExtension { /** * @var array */ protected $allowed = array(); /** * @param $allowed */ public function __construct($allowed) { parent::__construct(); if (!is_array($allowed)) { $allowed = func_get_args(); } $this->allowed = $allowed; } /** * @throws RuntimeException * @return bool */ public function getABTesting() { $args = func_get_args(); $num = count($args); if ($num === 0) { throw new RuntimeException('Need at least one argument to ABTestingExtension::getABTesting'); } elseif ($num === 1) { $args = explode('_', $args[0]); } list($flag, $val) = $args; if (isset($_GET[$flag]) && in_array($_GET[$flag], $this->allowed)) { $flag = $_GET[$flag]; } return $val == $flag; } } |