當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Generator::name方法代碼示例

本文整理匯總了PHP中Faker\Generator::name方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generator::name方法的具體用法?PHP Generator::name怎麽用?PHP Generator::name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Faker\Generator的用法示例。


在下文中一共展示了Generator::name方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testNameReturnsFirstNameAndLastName

 public function testNameReturnsFirstNameAndLastName()
 {
     $faker = new Generator();
     $faker->addProvider(new Person($faker));
     $this->assertContains($faker->name(), array('John Doe', 'Jane Doe'));
     $this->assertContains($faker->name('foobar'), array('John Doe', 'Jane Doe'));
     $this->assertContains($faker->name('male'), array('John Doe'));
     $this->assertContains($faker->name('female'), array('Jane Doe'));
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:9,代碼來源:PersonTest.php

示例2: generateReference

 /**
  * Generates a student convention reference from the student full name and the date of signature of the convention.
  *
  * @param \DateTime   $dateOfSignature
  * @param string|null $fullname        If is null, a random name is used instead
  *
  * @return string
  */
 public function generateReference(\DateTime $dateOfSignature, $fullname = null)
 {
     if (null === $fullname || '' === $fullname) {
         // It does not matter if the Faker instance is not based on the application locale as we don't really
         // care of the real value of the name. Keeping this avoid having to inject a faker instance which is
         // more difficul to properly test.
         $fullname = $this->faker->name();
     }
     $fullnameParts = array_merge(explode(' ', $this->normalizeString($fullname)), ['a', 'b', 'c', 'd', 'e', 'f']);
     $reference = '';
     foreach ($fullnameParts as $part) {
         $referenceLength = strlen($reference);
         if (6 === $referenceLength) {
             break;
         }
         $remaining = 6 - $referenceLength;
         if (3 < $remaining) {
             $remaining = 3;
         }
         $reference .= substr($part, 0, $remaining);
     }
     $reference .= $dateOfSignature->format('Ymd');
     return strtoupper($reference);
 }
開發者ID:EllynB,項目名稱:Incipio,代碼行數:32,代碼來源:StudentConventionProvider.php

示例3: getDummyData

 public function getDummyData(Generator $faker, array $customValues = array())
 {
     return ['comunidad' => $faker->company, 'tipo_secretariado_id' => rand(1, 3), 'responsable' => $faker->name($gender = null | 'male' | 'female'), 'direccion' => $faker->randomElement(['Numancia, 22', 'Escaleritas, 128', 'Carvajal, 32']), 'cp' => $faker->randomElement(['35012', '35016', '35018', '35010', '32012']), 'pais_id' => 73, 'provincia_id' => 1, 'localidad_id' => $faker->biasedNumberBetween($min = 1, $max = 34, $function = 'sqrt'), 'email_solicitud' => $faker->email, 'email_envio' => $faker->email, 'web' => $faker->url, 'facebook' => $faker->url, 'telefono1' => $faker->randomElement(['615324789', '928276589', '627456896', '615856912']), 'telefono2' => $faker->randomElement(['', '', '928278956', '928564285']), 'tipo_comunicacion_preferida_id' => rand(1, 2), 'observaciones' => $faker->text($maxNbChars = 200)];
 }
開發者ID:antoniobec,項目名稱:palencia,代碼行數:4,代碼來源:ComunidadesTableSeeder.php


注:本文中的Faker\Generator::name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。