当前位置: 首页>>代码示例>>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;未经允许,请勿转载。