Neos\Eel\Helper\MathHelper::randomInt PHP Method

randomInt() public method

That means a result will always be greater than or equal to min and less than or equal to max.
public randomInt ( integer $min, integer $max ) : integer
$min integer The lower bound for the random number (inclusive)
$max integer The upper bound for the random number (inclusive)
return integer A random number between min and max (inclusive), that is from [min, max]
    public function randomInt($min, $max)
    {
        return mt_rand($min, $max);
    }

Usage Example

 /**
  * @test
  */
 public function randomIntReturnsARandomResultFromMinToMaxExclusive()
 {
     $helper = new MathHelper();
     $min = 10;
     $max = 42;
     $r1 = $helper->randomInt($min, $max);
     $atLeastOneRandomResult = false;
     for ($i = 0; $i < 100; $i++) {
         $ri = $helper->randomInt($min, $max);
         if ($ri !== $r1) {
             $atLeastOneRandomResult = true;
         }
         $this->assertLessThanOrEqual($max, $ri);
         $this->assertGreaterThanOrEqual($min, $ri);
     }
     $this->assertTrue($atLeastOneRandomResult, 'random() should return a random result');
 }