refactoring of ab classes
This commit is contained in:
parent
baf43e21f9
commit
280f7f01b1
|
@ -7,11 +7,11 @@ namespace App\Core\Ab;
|
|||
*
|
||||
* @author Simon Vieille <simon@deblan.fr>
|
||||
*/
|
||||
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];
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace App\Core\Ab;
|
|||
*
|
||||
* @author Simon Vieille <simon@deblan.fr>
|
||||
*/
|
||||
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 = '';
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@
|
|||
<div class="col-md-12">
|
||||
{{ form_row(form.hasAbTest) }}
|
||||
</div>
|
||||
<div class="col-md-6 {% if not form.vars.data.abTestCode %}d-none{% endif %}">
|
||||
<div class="col-md-6 {% if not form.vars.data.hasAbTest %}d-none{% endif %}">
|
||||
{{ form_row(form.abTestCode) }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue