Complex classes like SplitTestAnalyzer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SplitTestAnalyzer, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 5 | final class SplitTestAnalyzer implements \IteratorAggregate  | 
            ||
| 6 | { | 
            ||
| 7 | |||
| 8 | const DEFAULT_SAMPLES = 5000;  | 
            ||
| 9 | |||
| 10 | /**  | 
            ||
| 11 | * @var int  | 
            ||
| 12 | */  | 
            ||
| 13 | private $numSamples;  | 
            ||
| 14 | |||
| 15 | /**  | 
            ||
| 16 | * @var Variation[]  | 
            ||
| 17 | */  | 
            ||
| 18 | private $variations = [];  | 
            ||
| 19 | |||
| 20 | /**  | 
            ||
| 21 | * @var array  | 
            ||
| 22 | */  | 
            ||
| 23 | private $result;  | 
            ||
| 24 | |||
| 25 | /**  | 
            ||
| 26 | * BayesianPerformance constructor.  | 
            ||
| 27 | * @param int $numSamples  | 
            ||
| 28 | */  | 
            ||
| 29 | private function __construct(int $numSamples = self::DEFAULT_SAMPLES)  | 
            ||
| 33 | |||
| 34 | /**  | 
            ||
| 35 | * @param Variation[] ...$variations  | 
            ||
| 36 | * @throws \InvalidArgumentException  | 
            ||
| 37 | */  | 
            ||
| 38 | private function setVariations(Variation ...$variations)  | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * @param int $numSamples  | 
            ||
| 51 | * @return SplitTestAnalyzer  | 
            ||
| 52 | */  | 
            ||
| 53 | public static function create(int $numSamples = self::DEFAULT_SAMPLES): self  | 
            ||
| 57 | |||
| 58 | /**  | 
            ||
| 59 | * @param Variation[] ...$variations  | 
            ||
| 60 | * @return SplitTestAnalyzer  | 
            ||
| 61 | * @throws \InvalidArgumentException  | 
            ||
| 62 | */  | 
            ||
| 63 | public function withVariations(Variation ...$variations): self  | 
            ||
| 73 | |||
| 74 | /**  | 
            ||
| 75 | * @param Variation $variation  | 
            ||
| 76 | * @return float  | 
            ||
| 77 | */  | 
            ||
| 78 | public function getVariationProbability(Variation $variation): float  | 
            ||
| 84 | |||
| 85 | /**  | 
            ||
| 86 | * @param int $sort  | 
            ||
| 87 | * @return Variation[]  | 
            ||
| 88 | */  | 
            ||
| 89 | public function getOrderedVariations(int $sort = SORT_DESC): array  | 
            ||
| 103 | |||
| 104 | /**  | 
            ||
| 105 | * @return Variation|null  | 
            ||
| 106 | */  | 
            ||
| 107 | public function getBestVariation(): ?Variation  | 
            ||
| 116 | |||
| 117 | /**  | 
            ||
| 118 | * @return array  | 
            ||
| 119 | */  | 
            ||
| 120 | public function getResult()  | 
            ||
| 125 | |||
| 126 | public function getIterator()  | 
            ||
| 131 | |||
| 132 | /**  | 
            ||
| 133 | * @return mixed  | 
            ||
| 134 | * @throws \Exception  | 
            ||
| 135 | * @throws \InvalidArgumentException  | 
            ||
| 136 | */  | 
            ||
| 137 | private function computeProbabilities()  | 
            ||
| 171 | |||
| 172 | /**  | 
            ||
| 173 | * @param Variation[] ...$variations  | 
            ||
| 174 | * @throws \InvalidArgumentException  | 
            ||
| 175 | */  | 
            ||
| 176 | private function check(Variation ...$variations)  | 
            ||
| 184 | |||
| 185 | /**  | 
            ||
| 186 | * @return float  | 
            ||
| 187 | * @throws \Exception  | 
            ||
| 188 | */  | 
            ||
| 189 | private function getMathRandom(): float  | 
            ||
| 193 | |||
| 194 | /**  | 
            ||
| 195 | * @return float  | 
            ||
| 196 | * @throws \Exception  | 
            ||
| 197 | */  | 
            ||
| 198 | private function getRandn(): float  | 
            ||
| 210 | |||
| 211 | /**  | 
            ||
| 212 | * @param float $shape  | 
            ||
| 213 | * @return float  | 
            ||
| 214 | * @throws \Exception  | 
            ||
| 215 | */  | 
            ||
| 216 | private function getRandg(float $shape): float  | 
            ||
| 254 | |||
| 255 | /**  | 
            ||
| 256 | * @param float $alpha  | 
            ||
| 257 | * @param float $beta  | 
            ||
| 258 | * @return float  | 
            ||
| 259 | * @throws \Exception  | 
            ||
| 260 | */  | 
            ||
| 261 | private function getSample(float $alpha, float $beta): float  | 
            ||
| 269 | |||
| 270 | private function reset()  | 
            ||
| 275 | }  | 
            ||
| 276 | 
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.