| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | protected function getRandomPoint(PointCollectionInterface $points): PointInterface |
||
| 34 | { |
||
| 35 | if (count($points) == 0) { |
||
| 36 | throw new \LogicException("Unable to pick a random point out of an empty point collection"); |
||
| 37 | } |
||
| 38 | |||
| 39 | $num = mt_rand(0, count($points) - 1); |
||
| 40 | foreach ($points as $i => $point) { |
||
| 41 | if ($i > $num) { |
||
| 42 | break; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | assert(isset($point)); |
||
| 47 | return $point; |
||
|
|
|||
| 48 | } |
||
| 50 |