本文整理汇总了PHP中Zend\Math\Rand::getInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Rand::getInteger方法的具体用法?PHP Rand::getInteger怎么用?PHP Rand::getInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Math\Rand
的用法示例。
在下文中一共展示了Rand::getInteger方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveOrder
public function saveOrder(Order $order)
{
$order->id = Rand::getInteger(100000, 999999);
$this->getEventManager()->trigger('preOrder', __CLASS__);
$filePath = realpath(BIG5_ROOT . '/data/order') . '/';
$fileName = $filePath . $order->id . '.txt';
file_put_contents($fileName, serialize($order));
echo "Save order " . $order->id . "<br />";
$this->getEventManager()->trigger('postOrder', __CLASS__);
}
示例2: populatePerson
private function populatePerson(PersonEntity $person)
{
$genders = [0, 1, 2, 9];
$gender = $genders[Rand::getInteger(0, count($genders) - 1)];
$person->setGender($gender);
$person->setJobTitle('Software Engineer');
$person->setDepartment('Department');
if ($gender === 2) {
$person->setMaidenName('Maiden name');
}
$person->setNickname('Nickname');
}
示例3: formRand
public function formRand()
{
$bytes = Rand::getBytes(32, true);
$this->data->bytes = "Random bytes (in Base64): " . base64_encode($bytes);
$boolean = Rand::getBoolean();
$this->data->boolean = "Random boolean: " . ($boolean ? 'true' : 'false');
$integer = Rand::getInteger(0, 1000);
$this->data->integer = "Random integer in [0-1000]: " . $integer;
$float = Rand::getFloat();
$this->data->float = "Random float in [0-1): " . $float;
$string = Rand::getString(32, 'abcdefghijklmnopqrstuvwxyz', true);
$this->data->string = "Random string in latin alphabet:" . $string;
$this->render();
}
示例4: generateWord
/**
* Generate new random word
*
* @return string
*/
protected function generateWord()
{
$word = '';
$wordLen = $this->getWordLen();
$vowels = $this->useNumbers ? static::$VN : static::$V;
$consonants = $this->useNumbers ? static::$CN : static::$C;
$totIndexCon = count($consonants) - 1;
$totIndexVow = count($vowels) - 1;
for ($i = 0; $i < $wordLen; $i = $i + 2) {
// generate word with mix of vowels and consonants
$consonant = $consonants[Rand::getInteger(0, $totIndexCon, true)];
$vowel = $vowels[Rand::getInteger(0, $totIndexVow, true)];
$word .= $consonant . $vowel;
}
if (strlen($word) > $wordLen) {
$word = substr($word, 0, $wordLen);
}
return $word;
}
示例5: generateCode
public function generateCode()
{
// Generate code_public
$private = Rand::getInteger(100000, 999999);
// Generate code_private
// Without 0 o
$public = Rand::getString(6, 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789', true);
// Set values
$result = array('public' => $public, 'private' => $private);
return $result;
}
示例6: roll
public function roll()
{
return Rand::getInteger(1, 6);
}
示例7: testIntegerRangeFail
public function testIntegerRangeFail()
{
$this->setExpectedException('Zend\\Math\\Exception\\DomainException', 'min parameter must be lower than max parameter');
$rand = Rand::getInteger(100, 0);
}
示例8: getInteger
/**
* Generate random integer value
*
* @param integer $min lowest value to be returned
* @param integer $max highest value to be returned
* @return integer
*/
public function getInteger($min, $max)
{
return \Zend\Math\Rand::getInteger($min, $max);
}
示例9: testIntegerRangeOverflow
public function testIntegerRangeOverflow()
{
$values = 0;
$cycles = 100;
for ($i = 0; $i < $cycles; $i++) {
$values += Rand::getInteger(0, PHP_INT_MAX);
}
$this->assertFalse($values === 0);
}
示例10: testCanFindLatestVersion
public function testCanFindLatestVersion()
{
$projectTest = new ProjectTest();
/**
* @var $project Project
*/
$project = $projectTest->provider()[0][0];
$project->setProject("This is a testProject . " . Rand::getString(6));
$project->setNumber(Rand::getInteger(10000, 99999));
$project = $this->projectService->newEntity($project);
$this->projectService->getOptions()->setConsiderFppOnlyAsOfficialVersion(false);
$this->projectService = $this->projectService->setProject($project);
$latestVersion = $this->projectService->getLatestProjectVersion();
$this->assertInstanceOf('Project\\Entity\\Version\\Version', $latestVersion);
}
示例11: __construct
public function __construct()
{
$this->token = Rand::getInteger(1, self::MAX_TOKEN);
}