private function populateGeneral(AbstractContact $contact) { $contact->setNotes('This is a note for this contact.'); if (Rand::getFloat(true) < 0.8) { $contact->setDisplayName(Rand::getString(32)); } }
/** * PostIdを生成する * @param $cmd saltとして使用する文字列(通常はプラグイン名) * @return string */ public static function generate($cmd = '') { global $session; $idstring = md5($cmd . Rand::getFloat()); // PostIDの値の中身は、ホストを入力 $session->offsetSet(self::POSTID_SESSION_PREFIX . $idstring, REMOTE_ADDR); // 有効期限を設定 $session->setExpirationSeconds(self::POSTID_SESSION_EXPIRE, self::POSTID_SESSION_PREFIX . $idstring); return $idstring; }
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(); }
public function testRandFloat() { for ($length = 1; $length < 512; $length++) { $rand = Rand::getFloat(); $this->assertTrue(is_float($rand)); $this->assertTrue($rand >= 0 && $rand <= 1); } }