diff --git a/src/core/Ab/AbContainer.php b/src/core/Ab/AbContainer.php index 0c947b8..a32ff76 100644 --- a/src/core/Ab/AbContainer.php +++ b/src/core/Ab/AbContainer.php @@ -7,11 +7,11 @@ namespace App\Core\Ab; * * @author Simon Vieille */ -class AbContainer +class AbContainer implements AbContainerInterface { protected array $tests = []; - public function add(AbTest $test): self + public function add(AbTestInterface $test): self { $this->tests[$test->getName()] = $test; @@ -23,7 +23,7 @@ class AbContainer return isset($this->tests[$name]); } - public function get(string $name): AbTest + public function get(string $name): AbTestInterface { return $this->tests[$name]; } diff --git a/src/core/Ab/AbTest.php b/src/core/Ab/AbTest.php index 51984ba..47f52c4 100644 --- a/src/core/Ab/AbTest.php +++ b/src/core/Ab/AbTest.php @@ -7,7 +7,7 @@ namespace App\Core\Ab; * * @author Simon Vieille */ -class AbTest +class AbTest implements AbTestInterface { protected $results; protected string $name; @@ -106,7 +106,7 @@ class AbTest krsort($this->probabilities); - $number = \rand(0, (int) \array_sum($this->probabilities) * 10); + $number = mt_rand(0, (int) array_sum($this->probabilities) * 10); $starter = 0; $return = ''; diff --git a/src/core/Resources/views/site/node_admin/_form.html.twig b/src/core/Resources/views/site/node_admin/_form.html.twig index 25b53f3..6ce769c 100644 --- a/src/core/Resources/views/site/node_admin/_form.html.twig +++ b/src/core/Resources/views/site/node_admin/_form.html.twig @@ -221,7 +221,7 @@
{{ form_row(form.hasAbTest) }}
-
+
{{ form_row(form.abTestCode) }}
diff --git a/src/core/Twig/Extension/AbTestExtension.php b/src/core/Twig/Extension/AbTestExtension.php index f3ebf8d..3727c17 100644 --- a/src/core/Twig/Extension/AbTestExtension.php +++ b/src/core/Twig/Extension/AbTestExtension.php @@ -3,9 +3,9 @@ namespace App\Core\Twig\Extension; use App\Core\Ab\AbContainer; -use App\Core\Ab\AbTest; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; +use App\Core\Ab\AbTestInterface; class AbTestExtension extends AbstractExtension { @@ -31,7 +31,7 @@ class AbTestExtension extends AbstractExtension return $this->container->has($name); } - public function get(string $name): AbTest + public function get(string $name): AbTestInterface { return $this->container->get($name); }