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


PHP Generator::url方法代碼示例

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


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

示例1: generateValueData

 /**
  * Generate value content based on backend type
  *
  * @param AbstractAttribute $attribute
  * @param string            $key
  *
  * @return string
  */
 protected function generateValueData(AbstractAttribute $attribute, $key)
 {
     $data = "";
     if (isset($this->forcedValues[$attribute->getCode()])) {
         return $this->forcedValues[$attribute->getCode()];
     }
     switch ($attribute->getBackendType()) {
         case "varchar":
             $validationRule = $attribute->getValidationRule();
             switch ($validationRule) {
                 case 'url':
                     $data = $this->faker->url();
                     break;
                 default:
                     $data = $this->faker->sentence();
                     break;
             }
             break;
         case "text":
             $data = $this->faker->sentence();
             break;
         case "date":
             $data = $this->faker->dateTimeBetween($attribute->getDateMin(), $attribute->getDateMax());
             $data = $data->format('Y-m-d');
             break;
         case "metric":
         case "decimal":
         case "prices":
             if ($attribute->getBackendType() && preg_match('/-' . self::METRIC_UNIT . '$/', $key)) {
                 $data = $attribute->getDefaultMetricUnit();
             } else {
                 $min = $attribute->getNumberMin() != null ? $attribute->getNumberMin() : self::DEFAULT_NUMBER_MIN;
                 $max = $attribute->getNumberMax() != null ? $attribute->getNumberMax() : self::DEFAULT_NUMBER_MAX;
                 $decimals = $attribute->isDecimalsAllowed() ? self::DEFAULT_NB_DECIMALS : 0;
                 $data = $this->faker->randomFloat($decimals, $min, $max);
             }
             break;
         case "boolean":
             $data = $this->faker->boolean() ? "1" : "0";
             break;
         case "option":
         case "options":
             $options = [];
             foreach ($attribute->getOptions() as $option) {
                 $options[] = $option;
             }
             $option = $this->faker->randomElement($options);
             if (is_object($option)) {
                 $data = $option->getCode();
             }
             break;
         default:
             $data = '';
             break;
     }
     return (string) $data;
 }
開發者ID:norfil,項目名稱:DataGeneratorBundle,代碼行數:65,代碼來源:AssociationCsvGenerator.php

示例2: generateVarcharData

 /**
  * Generate a varchar product value data
  *
  * @param AbstractAttribute attribute
  *
  * @return string
  */
 protected function generateVarcharData(AbstractAttribute $attribute)
 {
     $validationRule = $attribute->getValidationRule();
     switch ($validationRule) {
         case 'url':
             $varchar = $this->faker->url();
             break;
         default:
             $varchar = $this->faker->sentence();
             break;
     }
     return $varchar;
 }
開發者ID:norfil,項目名稱:DataGeneratorBundle,代碼行數:20,代碼來源:ProductGenerator.php

示例3: testUrlIsValid

 public function testUrlIsValid()
 {
     $url = $this->faker->url();
     $this->assertNotFalse(filter_var($url, FILTER_VALIDATE_URL));
 }
開發者ID:Kingsmanscode,項目名稱:blog,代碼行數:5,代碼來源:InternetTest.php

示例4: getDummyData

 public function getDummyData(Generator $faker)
 {
     return ["website" => $faker->url(), "comment" => $faker->paragraph(), "user_id" => $this->getRandomId("User"), "ticket_id" => $this->getRandomId("Ticket")];
 }
開發者ID:fgpayano,項目名稱:laravel_teachme,代碼行數:4,代碼來源:TicketCommentTableSeeder.php

示例5: getDummyData

 public function getDummyData(\Faker\Generator $faker, array $customValues = array())
 {
     return ['user_id' => $this->getRandom('User')->id, 'ticket_id' => $this->getRandom('Ticket')->id, 'comment' => $faker->paragraph(), 'link' => $faker->randomElement(['', '', $faker->url()])];
 }
開發者ID:ariels78,項目名稱:TeachMe,代碼行數:4,代碼來源:TicketCommentTableSeeder.php


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