I am making a way to organize a user into groups and you need a way to test them. For example, I have a gender verification method that returns true if there is no gender imbalance and false if there is one. I also have similar methods for checking age distribution and checking genders. For each of these methods, I have a method that creates an optimized array of groups.
those. I have a method that optimizes groups by gender. I would name only one of these methods if the corresponding check returns false. The problem that I am facing is that when I optimize groups based on a specific criterion, that is, gender, there is a chance that the new optimized groups ruined another test criterion.
For example, if I check age, gender and skill level (my third test), and I find that there is an imbalance in age, start optimizing groups by age, then I can potentially ruin the gender or skill level. My solution to this problem was that if I could find a way to call all variants of the verification methods and break if the verification of all methods is correct (all checks return true, all groups have good balances by age, gender and skill level).
Example: Let A, B, and C be test methods and optimize_A, optimize_B, optimize_C be optimized group make methods. I need to go through validation methods 3! (because there are three validation methods, and I need to run ABC, ACB, BAC, BCA, CAB, CBA). OR I could make a while loop and break if the method checks all (), returns true (all checks return true, all have good distributions) and abort once when I run all combinations of verification methods.
Can someone help me with this problem? Please keep in mind that I am a beginner programmer and have never done anything like this before. Thanks
Edit :
How can I do something like this piece of JavaScript code in php?
var arr = [check1, check2, check3], rand = Math.floor(Math.random() * arr.length), func = arr[rand]; func();
Here is my attempt:
<?php $checks_to_run = array('check_gender','check_age','check_skill_level'); $rand = floor(rand(0, count($checks_to_run) - 1)); $func = $checks_to_run[$rand]; echo $this->.$func.($tmp);